diff options
author | stujones11 <stujones111@gmail.com> | 2018-06-24 20:50:57 +0100 |
---|---|---|
committer | sfan5 <sfan5@live.de> | 2018-10-29 15:37:44 +0100 |
commit | 323c8600450a5ae3893de9ba1d04095589c5b06c (patch) | |
tree | f38afffdc33c85c5964c1eaa650675508a9248b4 /src/gui/guiPasswordChange.cpp | |
parent | 0d54399be2af37e334f3506bd09da85ad932b92f (diff) | |
download | minetest-323c8600450a5ae3893de9ba1d04095589c5b06c.tar.gz minetest-323c8600450a5ae3893de9ba1d04095589c5b06c.tar.bz2 minetest-323c8600450a5ae3893de9ba1d04095589c5b06c.zip |
Move touchscreen input handling to base GUIModalMenu class
Diffstat (limited to 'src/gui/guiPasswordChange.cpp')
-rw-r--r-- | src/gui/guiPasswordChange.cpp | 48 |
1 files changed, 46 insertions, 2 deletions
diff --git a/src/gui/guiPasswordChange.cpp b/src/gui/guiPasswordChange.cpp index 46de2026c..14e28cd36 100644 --- a/src/gui/guiPasswordChange.cpp +++ b/src/gui/guiPasswordChange.cpp @@ -23,7 +23,8 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include <IGUIButton.h> #include <IGUIStaticText.h> #include <IGUIFont.h> - +#include "keycode.h" +#include "porting.h" #include "gettext.h" const int ID_oldPassword = 256; @@ -180,6 +181,9 @@ void GUIPasswordChange::drawMenu() driver->draw2DRectangle(bgcolor, AbsoluteRect, &AbsoluteClippingRect); gui::IGUIElement::draw(); +#ifdef __ANDROID__ + getAndroidUIInput(); +#endif } void GUIPasswordChange::acceptInput() @@ -211,10 +215,14 @@ bool GUIPasswordChange::processInput() bool GUIPasswordChange::OnEvent(const SEvent &event) { if (event.EventType == EET_KEY_INPUT_EVENT) { - if (event.KeyInput.Key == KEY_ESCAPE && event.KeyInput.PressedDown) { + // clang-format off + if ((event.KeyInput.Key == KEY_ESCAPE || + event.KeyInput.Key == KEY_CANCEL) && + event.KeyInput.PressedDown) { quitMenu(); return true; } + // clang-format on if (event.KeyInput.Key == KEY_RETURN && event.KeyInput.PressedDown) { acceptInput(); if (processInput()) @@ -259,3 +267,39 @@ bool GUIPasswordChange::OnEvent(const SEvent &event) return Parent ? Parent->OnEvent(event) : false; } + +std::string GUIPasswordChange::getNameByID(s32 id) +{ + switch (id) { + case ID_oldPassword: + return "old_password"; + case ID_newPassword1: + return "new_password_1"; + case ID_newPassword2: + return "new_password_2"; + } + return ""; +} + +#ifdef __ANDROID__ +bool GUIPasswordChange::getAndroidUIInput() +{ + if (!hasAndroidUIInput()) + return false; + + gui::IGUIElement *e = nullptr; + if (m_jni_field_name == "old_password") + e = getElementFromId(ID_oldPassword); + else if (m_jni_field_name == "new_password_1") + e = getElementFromId(ID_newPassword1); + else if (m_jni_field_name == "new_password_2") + e = getElementFromId(ID_newPassword2); + + if (e) { + std::string text = porting::getInputDialogValue(); + e->setText(utf8_to_wide(text).c_str()); + } + m_jni_field_name.clear(); + return false; +} +#endif |