src/events/SDL_keyboard.c
changeset 4434 5c64052fb476
parent 4429 faa9fc8e7f67
child 4435 e953700da4ca
     1.1 --- a/src/events/SDL_keyboard.c	Thu Apr 15 21:27:32 2010 -0700
     1.2 +++ b/src/events/SDL_keyboard.c	Thu Apr 15 22:14:26 2010 -0700
     1.3 @@ -679,6 +679,8 @@
     1.4      if (keyboard->focus) {
     1.5          SDL_SendWindowEvent(keyboard->focus, SDL_WINDOWEVENT_FOCUS_GAINED,
     1.6                              0, 0);
     1.7 +        if (SDL_EventState(SDL_TEXTINPUT, SDL_QUERY))
     1.8 +            SDL_StartTextInput();
     1.9      }
    1.10  }
    1.11  
    1.12 @@ -839,10 +841,14 @@
    1.13  }
    1.14  
    1.15  int
    1.16 -SDL_SendEditingText(const char *text, int start, int length)
    1.17 +SDL_SendEditingText(int index, const char *text, int start, int length)
    1.18  {
    1.19 +    SDL_Keyboard *keyboard = SDL_GetKeyboard(index);
    1.20      int posted;
    1.21  
    1.22 +    if (!keyboard)
    1.23 +        return 0;
    1.24 +
    1.25      /* Post the event, if desired */
    1.26      posted = 0;
    1.27      if (SDL_GetEventState(SDL_TEXTEDITING) == SDL_ENABLE) {
    1.28 @@ -851,6 +857,7 @@
    1.29          event.edit.start = start;
    1.30          event.edit.length = length;
    1.31          SDL_strlcpy(event.edit.text, text, SDL_arraysize(event.text.text));
    1.32 +        event.edit.windowID = keyboard->focus->id;
    1.33          posted = (SDL_PushEvent(&event) > 0);
    1.34      }
    1.35      return (posted);