aboutsummaryrefslogtreecommitdiff
path: root/gui/widgets
diff options
context:
space:
mode:
authorAlexander Tkachev2016-07-17 14:01:52 +0600
committerAlexander Tkachev2016-08-24 16:07:55 +0600
commit75fbecf616a9b3e2592cffa8000f92237db05640 (patch)
tree2be0d4a72605f3e3ddf5fbfb962f6d469f3785a7 /gui/widgets
parent6c0f491c4f8e809d5d2e5fd070461db1c9777958 (diff)
downloadscummvm-rg350-75fbecf616a9b3e2592cffa8000f92237db05640.tar.gz
scummvm-rg350-75fbecf616a9b3e2592cffa8000f92237db05640.tar.bz2
scummvm-rg350-75fbecf616a9b3e2592cffa8000f92237db05640.zip
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.
Diffstat (limited to 'gui/widgets')
-rw-r--r--gui/widgets/editable.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/gui/widgets/editable.cpp b/gui/widgets/editable.cpp
index 4f7e584c14..6c63074fd1 100644
--- a/gui/widgets/editable.cpp
+++ b/gui/widgets/editable.cpp
@@ -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.
//