src/video/SDL_video.c
changeset 6654 2ecfb25be1e2
parent 6620 62fe18dc6841
child 6662 698c2e533a7e
     1.1 --- a/src/video/SDL_video.c	Sun Nov 04 20:20:53 2012 -0800
     1.2 +++ b/src/video/SDL_video.c	Sun Nov 04 21:53:28 2012 -0800
     1.3 @@ -2771,19 +2771,47 @@
     1.4  void
     1.5  SDL_StartTextInput(void)
     1.6  {
     1.7 +    SDL_Window *window;
     1.8 +
     1.9 +    /* First, enable text events */
    1.10 +    SDL_EventState(SDL_TEXTINPUT, SDL_ENABLE);
    1.11 +    SDL_EventState(SDL_TEXTEDITING, SDL_ENABLE);
    1.12 +
    1.13 +    /* Then show the on-screen keyboard, if any */
    1.14 +    window = SDL_GetFocusWindow();
    1.15 +    if (window && _this && _this->SDL_ShowScreenKeyboard) {
    1.16 +        _this->SDL_ShowScreenKeyboard(_this, window);
    1.17 +    }
    1.18 +
    1.19 +    /* Finally start the text input system */
    1.20      if (_this && _this->StartTextInput) {
    1.21          _this->StartTextInput(_this);
    1.22      }
    1.23 -    SDL_EventState(SDL_TEXTINPUT, SDL_ENABLE);
    1.24 -    SDL_EventState(SDL_TEXTEDITING, SDL_ENABLE);
    1.25 +}
    1.26 +
    1.27 +SDL_bool
    1.28 +SDL_IsTextInputActive(void)
    1.29 +{
    1.30 +    return (SDL_GetEventState(SDL_TEXTINPUT) == SDL_ENABLE);
    1.31  }
    1.32  
    1.33  void
    1.34  SDL_StopTextInput(void)
    1.35  {
    1.36 +    SDL_Window *window;
    1.37 +
    1.38 +    /* Stop the text input system */
    1.39      if (_this && _this->StopTextInput) {
    1.40          _this->StopTextInput(_this);
    1.41      }
    1.42 +
    1.43 +    /* Hide the on-screen keyboard, if any */
    1.44 +    window = SDL_GetFocusWindow();
    1.45 +    if (window && _this && _this->SDL_HideScreenKeyboard) {
    1.46 +        _this->SDL_HideScreenKeyboard(_this, window);
    1.47 +    }
    1.48 +
    1.49 +    /* Finally disable text events */
    1.50      SDL_EventState(SDL_TEXTINPUT, SDL_DISABLE);
    1.51      SDL_EventState(SDL_TEXTEDITING, SDL_DISABLE);
    1.52  }
    1.53 @@ -2797,41 +2825,14 @@
    1.54  }
    1.55  
    1.56  SDL_bool
    1.57 -SDL_HasScreenKeyboardSupport(SDL_Window *window)
    1.58 +SDL_HasScreenKeyboardSupport(void)
    1.59  {
    1.60 -    if (window && _this && _this->SDL_HasScreenKeyboardSupport) {
    1.61 -        return _this->SDL_HasScreenKeyboardSupport(_this, window);
    1.62 +    if (_this && _this->SDL_HasScreenKeyboardSupport) {
    1.63 +        return _this->SDL_HasScreenKeyboardSupport(_this);
    1.64      }
    1.65      return SDL_FALSE;
    1.66  }
    1.67  
    1.68 -int
    1.69 -SDL_ShowScreenKeyboard(SDL_Window *window)
    1.70 -{
    1.71 -    if (window && _this && _this->SDL_ShowScreenKeyboard) {
    1.72 -        return _this->SDL_ShowScreenKeyboard(_this, window);
    1.73 -    }
    1.74 -    return -1;
    1.75 -}
    1.76 -
    1.77 -int
    1.78 -SDL_HideScreenKeyboard(SDL_Window *window)
    1.79 -{
    1.80 -    if (window && _this && _this->SDL_HideScreenKeyboard) {
    1.81 -        return _this->SDL_HideScreenKeyboard(_this, window);
    1.82 -    }
    1.83 -    return -1;
    1.84 -}
    1.85 -
    1.86 -int
    1.87 -SDL_ToggleScreenKeyboard(SDL_Window *window)
    1.88 -{
    1.89 -    if (window && _this && _this->SDL_ToggleScreenKeyboard) {
    1.90 -        return _this->SDL_ToggleScreenKeyboard(_this, window);
    1.91 -    }
    1.92 -    return -1;
    1.93 -}
    1.94 -
    1.95  SDL_bool
    1.96  SDL_IsScreenKeyboardShown(SDL_Window *window)
    1.97  {