From 0dbe22fd77994c05fcd587363b726c22c40b1917 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 22 Sep 2013 20:33:33 +0300 Subject: add support for show/hide keyboard in SDL2 on Android. --- src/actionmanager.cpp | 5 ++++- src/client.cpp | 9 +++++++++ src/client.h | 3 +-- src/game.cpp | 4 +--- 4 files changed, 15 insertions(+), 6 deletions(-) (limited to 'src') 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; -- cgit v1.2.3-70-g09d2