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/guiConfirmRegistration.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/guiConfirmRegistration.cpp')
-rw-r--r-- | src/gui/guiConfirmRegistration.cpp | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/src/gui/guiConfirmRegistration.cpp b/src/gui/guiConfirmRegistration.cpp index 7f5aec264..9ffd9563e 100644 --- a/src/gui/guiConfirmRegistration.cpp +++ b/src/gui/guiConfirmRegistration.cpp @@ -43,6 +43,9 @@ GUIConfirmRegistration::GUIConfirmRegistration(gui::IGUIEnvironment *env, m_client(client), m_playername(playername), m_password(password), m_address(address), m_aborted(aborted) { +#ifdef __ANDROID__ + m_touchscreen_visible = false; +#endif } GUIConfirmRegistration::~GUIConfirmRegistration() @@ -157,6 +160,9 @@ void GUIConfirmRegistration::drawMenu() driver->draw2DRectangle(bgcolor, AbsoluteRect, &AbsoluteClippingRect); gui::IGUIElement::draw(); +#ifdef __ANDROID__ + getAndroidUIInput(); +#endif } void GUIConfirmRegistration::closeMenu(bool goNext) @@ -193,10 +199,14 @@ bool GUIConfirmRegistration::processInput() bool GUIConfirmRegistration::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) { closeMenu(false); return true; } + // clang-format on if (event.KeyInput.Key == KEY_RETURN && event.KeyInput.PressedDown) { acceptInput(); if (processInput()) @@ -239,3 +249,19 @@ bool GUIConfirmRegistration::OnEvent(const SEvent &event) return false; } + +#ifdef __ANDROID__ +bool GUIConfirmRegistration::getAndroidUIInput() +{ + if (!hasAndroidUIInput() || m_jni_field_name != "password") + return false; + + std::string text = porting::getInputDialogValue(); + gui::IGUIElement *e = getElementFromId(ID_confirmPassword); + if (e) + e->setText(utf8_to_wide(text).c_str()); + + m_jni_field_name.clear(); + return false; +} +#endif |