summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-09-22 20:33:33 +0300
committerAndrei Karas <akaras@inbox.ru>2013-09-22 20:33:33 +0300
commit0dbe22fd77994c05fcd587363b726c22c40b1917 (patch)
treeb26f3904e1a07d2f5769cac4260adf75387f75e8
parentce1b6c9c3c0166853089a247add9c2baa016c5f0 (diff)
downloadmanaverse-0dbe22fd77994c05fcd587363b726c22c40b1917.tar.gz
manaverse-0dbe22fd77994c05fcd587363b726c22c40b1917.tar.bz2
manaverse-0dbe22fd77994c05fcd587363b726c22c40b1917.tar.xz
manaverse-0dbe22fd77994c05fcd587363b726c22c40b1917.zip
add support for show/hide keyboard in SDL2 on Android.
-rw-r--r--src/actionmanager.cpp5
-rw-r--r--src/client.cpp9
-rw-r--r--src/client.h3
-rw-r--r--src/game.cpp4
4 files changed, 15 insertions, 6 deletions
diff --git a/src/actionmanager.cpp b/src/actionmanager.cpp
index 3bbc30ffc..eb2501b53 100644
--- a/src/actionmanager.cpp
+++ b/src/actionmanager.cpp
@@ -1111,7 +1111,10 @@ impHandler0(showKeyboard)
{
#ifdef ANDROID
#ifdef USE_SDL2
-// +++ need add support
+ if (SDL_IsTextInputActive())
+ SDL_StopTextInput();
+ else
+ SDL_StartTextInput();
#else
SDL_ANDROID_ToggleScreenKeyboardTextInput(nullptr);
#endif
diff --git a/src/client.cpp b/src/client.cpp
index 0b913c601..c4787d9a3 100644
--- a/src/client.cpp
+++ b/src/client.cpp
@@ -3170,6 +3170,15 @@ void Client::setIcon()
#endif
}
+bool Client::isKeyboardVisible() const
+{
+#ifdef USE_SDL2
+ return SDL_IsTextInputActive();
+#else
+ return mKeyboardHeight > 1;
+#endif
+}
+
#ifdef USE_SDL2
void Client::handleSDL2WindowEvent(const SDL_Event &event)
{
diff --git a/src/client.h b/src/client.h
index 6c1a7bff2..957c49fed 100644
--- a/src/client.h
+++ b/src/client.h
@@ -288,8 +288,7 @@ public:
std::string getSupportUrl() const A_WARN_UNUSED
{ return mCurrentServer.supportUrl; }
- bool isKeyboardVisible() const
- { return mKeyboardHeight > 1; }
+ bool isKeyboardVisible() const;
void setGuiAlpha(const float n)
{ mGuiAlpha = n; }
diff --git a/src/game.cpp b/src/game.cpp
index debc28515..ea47f3b08 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -1053,9 +1053,7 @@ void Game::handleInput()
client->setState(STATE_EXIT);
break;
#ifdef ANDROID
-#ifdef USE_SDL2
- // +++ probably need add support
-#else
+#ifndef USE_SDL2
case SDL_KEYBOARDSHOW:
client->updateScreenKeyboard(event.user.code);
break;