mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-06 00:55:50 +00:00
Add cut, copy & paste of text
This commit is contained in:
parent
74f7071b82
commit
3a3f2a37c8
@ -468,6 +468,41 @@ namespace MWInput
|
||||
|
||||
bool InputManager::keyPressed( const SDL_KeyboardEvent &arg )
|
||||
{
|
||||
// Cut, copy & paste
|
||||
MyGUI::Widget* focus = MyGUI::InputManager::getInstance().getKeyFocusWidget();
|
||||
if (focus)
|
||||
{
|
||||
MyGUI::EditBox* edit = focus->castType<MyGUI::EditBox>(false);
|
||||
if (edit && !edit->getEditReadOnly())
|
||||
{
|
||||
if (arg.keysym.sym == SDLK_v && (arg.keysym.mod & SDL_Keymod(KMOD_CTRL)))
|
||||
{
|
||||
char* text = SDL_GetClipboardText();
|
||||
|
||||
if (text)
|
||||
{
|
||||
edit->addText(MyGUI::UString(text));
|
||||
SDL_free(text);
|
||||
}
|
||||
}
|
||||
if (arg.keysym.sym == SDLK_x && (arg.keysym.mod & SDL_Keymod(KMOD_CTRL)))
|
||||
{
|
||||
std::string text = edit->getTextSelection();
|
||||
if (text.length())
|
||||
{
|
||||
SDL_SetClipboardText(text.c_str());
|
||||
edit->deleteTextSelection();
|
||||
}
|
||||
}
|
||||
if (arg.keysym.sym == SDLK_c && (arg.keysym.mod & SDL_Keymod(KMOD_CTRL)))
|
||||
{
|
||||
std::string text = edit->getTextSelection();
|
||||
if (text.length())
|
||||
SDL_SetClipboardText(text.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mInputBinder->keyPressed (arg);
|
||||
|
||||
if(arg.keysym.sym == SDLK_RETURN
|
||||
|
@ -9,6 +9,7 @@
|
||||
<!-- Log window -->
|
||||
<Widget type="EditBox" skin="MW_ConsoleLog" position="5 5 380 328" align="Stretch" name="list_History">
|
||||
<Property key="MultiLine" value="1"/>
|
||||
<Property key="ReadOnly" value="true"/>
|
||||
</Widget>
|
||||
|
||||
<!-- Command line -->
|
||||
|
Loading…
Reference in New Issue
Block a user