From c37958a7f32d4ecb257d8fb6e164638b759010d1 Mon Sep 17 00:00:00 2001 From: David Capello Date: Tue, 9 Sep 2014 09:52:37 -0300 Subject: [PATCH] Fix focus movement in ui::Entry widget on Mac OS X platform --- src/ui/entry.cpp | 3 +++ src/ui/manager.cpp | 14 ++++++++++++++ src/ui/manager.h | 5 +++-- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/ui/entry.cpp b/src/ui/entry.cpp index 131733467..ffffca674 100644 --- a/src/ui/entry.cpp +++ b/src/ui/entry.cpp @@ -279,6 +279,9 @@ bool Entry::onProcessMessage(Message* msg) case kKeyV: cmd = EntryCmd::Paste; break; } } + else if (getManager()->isFocusMovementKey(msg)) { + break; + } else if (keymsg->unicodeChar() >= 32) { // Ctrl and Alt must be unpressed to insert a character // in the text-field. diff --git a/src/ui/manager.cpp b/src/ui/manager.cpp index 3823e8443..49d5b9eb6 100644 --- a/src/ui/manager.cpp +++ b/src/ui/manager.cpp @@ -1029,6 +1029,20 @@ void Manager::removeMessageFilterFor(Widget* widget) } } +bool Manager::isFocusMovementKey(Message* msg) +{ + switch (static_cast(msg)->scancode()) { + + case kKeyTab: + case kKeyLeft: + case kKeyRight: + case kKeyUp: + case kKeyDown: + return true; + } + return false; +} + /* configures the window for begin the loop */ void Manager::_openWindow(Window* window) { diff --git a/src/ui/manager.h b/src/ui/manager.h index 93ff1155c..0739b50c4 100644 --- a/src/ui/manager.h +++ b/src/ui/manager.h @@ -24,8 +24,7 @@ namespace ui { class Timer; class Window; - class Manager : public Widget - { + class Manager : public Widget { public: static Manager* getDefault() { return m_defaultManager; @@ -79,6 +78,8 @@ namespace ui { LayoutIO* getLayoutIO(); + bool isFocusMovementKey(Message* msg); + void _openWindow(Window* window); void _closeWindow(Window* window, bool redraw_background);