Browse Source

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.
pull/183/head^2
Vladimír Vondruš 10 years ago
parent
commit
8d3fb52a7f
  1. 13
      src/Magnum/Platform/Sdl2Application.cpp
  2. 21
      src/Magnum/Platform/Sdl2Application.h

13
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

21
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

Loading…
Cancel
Save