mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-04 18:06:26 +00:00
GUI: Add Ctrl+V handling in EditableWidget
In SDL2 there is SDL_GetClipboardText(), so EditableWidget could support pasting into it. No copying yet, as there is no selecting.
This commit is contained in:
parent
6c0f491c4f
commit
75fbecf616
@ -20,6 +20,13 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef USE_SDL2
|
||||
#define FORBIDDEN_SYMBOL_ALLOW_ALL
|
||||
|
||||
#include <SDL2/SDL.h>
|
||||
#include <SDL2/SDL_clipboard.h>
|
||||
#endif
|
||||
|
||||
#include "common/rect.h"
|
||||
#include "common/system.h"
|
||||
#include "gui/widgets/editable.h"
|
||||
@ -185,6 +192,25 @@ bool EditableWidget::handleKeyDown(Common::KeyState state) {
|
||||
forcecaret = true;
|
||||
break;
|
||||
|
||||
#ifdef USE_SDL2
|
||||
case Common::KEYCODE_v:
|
||||
if (state.flags & Common::KBD_CTRL) {
|
||||
if (SDL_HasClipboardText() == SDL_TRUE) {
|
||||
char *text = SDL_GetClipboardText();
|
||||
if (text != nullptr) {
|
||||
for (char *ptr = text; *ptr; ++ptr) {
|
||||
if (tryInsertChar(*ptr, _caretPos))
|
||||
++_caretPos;
|
||||
}
|
||||
dirty = true;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
defaultKeyDownHandler(state, dirty, forcecaret, handled);
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
#ifdef MACOSX
|
||||
// Let ctrl-a / ctrl-e move the caret to the start / end of the line.
|
||||
//
|
||||
|
Loading…
x
Reference in New Issue
Block a user