src/events/SDL_keyboard.c
changeset 4435 e953700da4ca
parent 4434 5c64052fb476
child 4437 25e45611fa3d
     1.1 --- a/src/events/SDL_keyboard.c	Thu Apr 15 22:14:26 2010 -0700
     1.2 +++ b/src/events/SDL_keyboard.c	Thu Apr 15 22:27:01 2010 -0700
     1.3 @@ -679,8 +679,10 @@
     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 +
     1.9 +        if (SDL_EventState(SDL_TEXTINPUT, SDL_QUERY)) {
    1.10              SDL_StartTextInput();
    1.11 +        }
    1.12      }
    1.13  }
    1.14  
    1.15 @@ -832,6 +834,7 @@
    1.16      if (SDL_GetEventState(SDL_TEXTINPUT) == SDL_ENABLE) {
    1.17          SDL_Event event;
    1.18          event.text.type = SDL_TEXTINPUT;
    1.19 +        event.text.windowID = keyboard->focus ? keyboard->focus->id : 0;
    1.20          event.text.which = (Uint8) index;
    1.21          SDL_strlcpy(event.text.text, text, SDL_arraysize(event.text.text));
    1.22          event.text.windowID = keyboard->focus->id;
    1.23 @@ -846,18 +849,20 @@
    1.24      SDL_Keyboard *keyboard = SDL_GetKeyboard(index);
    1.25      int posted;
    1.26  
    1.27 -    if (!keyboard)
    1.28 +    if (!keyboard) {
    1.29          return 0;
    1.30 +    }
    1.31  
    1.32      /* Post the event, if desired */
    1.33      posted = 0;
    1.34      if (SDL_GetEventState(SDL_TEXTEDITING) == SDL_ENABLE) {
    1.35          SDL_Event event;
    1.36          event.edit.type = SDL_TEXTEDITING;
    1.37 +        event.edit.windowID = keyboard->focus ? keyboard->focus->id : 0;
    1.38 +        event.text.which = (Uint8) index;
    1.39          event.edit.start = start;
    1.40          event.edit.length = length;
    1.41 -        SDL_strlcpy(event.edit.text, text, SDL_arraysize(event.text.text));
    1.42 -        event.edit.windowID = keyboard->focus->id;
    1.43 +        SDL_strlcpy(event.edit.text, text, SDL_arraysize(event.edit.text));
    1.44          posted = (SDL_PushEvent(&event) > 0);
    1.45      }
    1.46      return (posted);