From 8d3fb52a7f67921c33afd62ee27396a9b8c3ab6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Mon, 25 Apr 2016 11:11:23 +0200 Subject: [PATCH] Platform: split text input rect setup into separate function. * It might change during the text editing process and thus we need to reposition it. * And it's also not possible to connect a parameter-less signal to it on Clang, which is unfortunate. --- src/Magnum/Platform/Sdl2Application.cpp | 13 +++---------- src/Magnum/Platform/Sdl2Application.h | 21 +++++++++++---------- 2 files changed, 14 insertions(+), 20 deletions(-) diff --git a/src/Magnum/Platform/Sdl2Application.cpp b/src/Magnum/Platform/Sdl2Application.cpp index 18c14eb4e..70c2f00ea 100644 --- a/src/Magnum/Platform/Sdl2Application.cpp +++ b/src/Magnum/Platform/Sdl2Application.cpp @@ -452,16 +452,9 @@ void Sdl2Application::setMouseLocked(bool enabled) { } #ifndef CORRADE_TARGET_EMSCRIPTEN -void Sdl2Application::startTextInput(const Range2Di& rect) { - SDL_StartTextInput(); - if(!rect.size().isZero()) { - SDL_Rect r{rect.min().x(), rect.min().y(), rect.sizeX(), rect.sizeY()}; - SDL_SetTextInputRect(&r); - } -} - -void Sdl2Application::startTextInput() { - startTextInput({}); +void Sdl2Application::setTextInputRect(const Range2Di& rect) { + SDL_Rect r{rect.min().x(), rect.min().y(), rect.sizeX(), rect.sizeY()}; + SDL_SetTextInputRect(&r); } #endif diff --git a/src/Magnum/Platform/Sdl2Application.h b/src/Magnum/Platform/Sdl2Application.h index ea14d4a76..a04f63102 100644 --- a/src/Magnum/Platform/Sdl2Application.h +++ b/src/Magnum/Platform/Sdl2Application.h @@ -593,19 +593,12 @@ class Sdl2Application { * @brief Start text input * * Starts text input that will go to @ref textInputEvent() and - * @ref textEditingEvent(). The @p rect defines an area where the text - * is being displayed, for example to hint the system where to place - * on-screen keyboard. Ignored if empty. + * @ref textEditingEvent(). * @note Not available in @ref CORRADE_TARGET_EMSCRIPTEN "Emscripten". * @see @ref stopTextInput(), @ref isTextInputActive(), + * @ref setTextInputRect() */ - #ifdef DOXYGEN_GENERATING_OUTPUT - void startTextInput(const Range2Di& rect = {}); - #else - /* To avoid including the type in header */ - void startTextInput(const Range2Di& rect); - void startTextInput(); - #endif + void startTextInput() { SDL_StartTextInput(); } /** * @brief Stop text input @@ -616,6 +609,14 @@ class Sdl2Application { */ void stopTextInput() { SDL_StopTextInput(); } + /** + * @brief Set text input rectangle + * + * The @p rect defines an area where the text is being displayed, for + * example to hint the system where to place on-screen keyboard. + */ + void setTextInputRect(const Range2Di& rect); + #ifdef DOXYGEN_GENERATING_OUTPUT protected: #else