diff options
author | Andrei Karas <akaras@inbox.ru> | 2013-05-11 22:25:21 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2013-05-11 22:25:21 +0300 |
commit | 120ef46ea296729baee0c88c046008d8e18644fa (patch) | |
tree | 36ac86de113f11e60c31008ea15d286bb30d831d /src/gui/widgets | |
parent | c4d16b36a373ba5609360e2698372926d7f2dc0f (diff) | |
download | plus-120ef46ea296729baee0c88c046008d8e18644fa.tar.gz plus-120ef46ea296729baee0c88c046008d8e18644fa.tar.bz2 plus-120ef46ea296729baee0c88c046008d8e18644fa.tar.xz plus-120ef46ea296729baee0c88c046008d8e18644fa.zip |
Add ability to show onscreen keyboard if input field focused.
Diffstat (limited to 'src/gui/widgets')
-rw-r--r-- | src/gui/widgets/popuplist.h | 2 | ||||
-rw-r--r-- | src/gui/widgets/textfield.cpp | 20 | ||||
-rw-r--r-- | src/gui/widgets/textfield.h | 6 |
3 files changed, 27 insertions, 1 deletions
diff --git a/src/gui/widgets/popuplist.h b/src/gui/widgets/popuplist.h index 5e0f4f260..59e04df63 100644 --- a/src/gui/widgets/popuplist.h +++ b/src/gui/widgets/popuplist.h @@ -25,7 +25,7 @@ #include "gui/widgets/popup.h" #include <guichan/actionlistener.hpp> -#include "guichan/focuslistener.hpp" +#include <guichan/focuslistener.hpp> #include <guichan/listmodel.hpp> #include "localconsts.h" diff --git a/src/gui/widgets/textfield.cpp b/src/gui/widgets/textfield.cpp index 73e01fb63..5d0621e1e 100644 --- a/src/gui/widgets/textfield.cpp +++ b/src/gui/widgets/textfield.cpp @@ -24,6 +24,7 @@ #include "client.h" #include "configuration.h" +#include "inputmanager.h" #include "keyevent.h" #include "gui/popupmenu.h" @@ -51,6 +52,7 @@ TextField::TextField(const Widget2 *const widget, gcn::ActionListener *const listener, std::string eventId, const bool sendAlwaysEvents): gcn::TextField(text), + gcn::FocusListener(), Widget2(widget), mSendAlwaysEvents(sendAlwaysEvents), mNumeric(false), @@ -66,6 +68,8 @@ TextField::TextField(const Widget2 *const widget, setFrameSize(2); mForegroundColor = getThemeColor(Theme::TEXTFIELD); + addFocusListener(this); + if (instances == 0) { if (Theme::instance()) @@ -529,6 +533,10 @@ void TextField::fontChanged() void TextField::mousePressed(gcn::MouseEvent &mouseEvent) { +#ifdef ANDROID + if (!Client::isKeyboardVisible()) + inputManager.executeAction(Input::KEY_SHOW_KEYBOARD); +#endif if (mouseEvent.getButton() == gcn::MouseEvent::RIGHT) { if (viewport) @@ -550,3 +558,15 @@ void TextField::mousePressed(gcn::MouseEvent &mouseEvent) gcn::TextField::mousePressed(mouseEvent); } } + +void TextField::focusGained(const gcn::Event &event A_UNUSED) +{ +#ifdef ANDROID + if (!Client::isKeyboardVisible()) + inputManager.executeAction(Input::KEY_SHOW_KEYBOARD); +#endif +} + +void TextField::focusLost(const gcn::Event &event A_UNUSED) +{ +} diff --git a/src/gui/widgets/textfield.h b/src/gui/widgets/textfield.h index 0c30fc819..0569d5d30 100644 --- a/src/gui/widgets/textfield.h +++ b/src/gui/widgets/textfield.h @@ -25,6 +25,7 @@ #include "gui/widgets/widget2.h" +#include <guichan/focuslistener.hpp> #include <guichan/widgets/textfield.hpp> #include "localconsts.h" @@ -39,6 +40,7 @@ class TextField; * \ingroup GUI */ class TextField : public gcn::TextField, + public gcn::FocusListener, public Widget2 { public: @@ -122,6 +124,10 @@ class TextField : public gcn::TextField, void handleCopy() const; + void focusGained(const gcn::Event &event); + + void focusLost(const gcn::Event &event); + protected: void drawCaret(gcn::Graphics* graphics, int x) override; |