diff src/events/SDL_keyboard.c @ 4434:5c64052fb476

changeset: 4433:25667ea797fa tag: tip user: Jiang Jiang <gzjjgod@gmail.com> date: Thu Apr 15 12:01:46 2010 +0800 summary: Add windowID to text editing event
author Sam Lantinga <slouken@libsdl.org>
date Thu, 15 Apr 2010 22:14:26 -0700
parents faa9fc8e7f67
children e953700da4ca
line wrap: on
line diff
--- a/src/events/SDL_keyboard.c	Thu Apr 15 21:27:32 2010 -0700
+++ b/src/events/SDL_keyboard.c	Thu Apr 15 22:14:26 2010 -0700
@@ -679,6 +679,8 @@
     if (keyboard->focus) {
         SDL_SendWindowEvent(keyboard->focus, SDL_WINDOWEVENT_FOCUS_GAINED,
                             0, 0);
+        if (SDL_EventState(SDL_TEXTINPUT, SDL_QUERY))
+            SDL_StartTextInput();
     }
 }
 
@@ -839,10 +841,14 @@
 }
 
 int
-SDL_SendEditingText(const char *text, int start, int length)
+SDL_SendEditingText(int index, const char *text, int start, int length)
 {
+    SDL_Keyboard *keyboard = SDL_GetKeyboard(index);
     int posted;
 
+    if (!keyboard)
+        return 0;
+
     /* Post the event, if desired */
     posted = 0;
     if (SDL_GetEventState(SDL_TEXTEDITING) == SDL_ENABLE) {
@@ -851,6 +857,7 @@
         event.edit.start = start;
         event.edit.length = length;
         SDL_strlcpy(event.edit.text, text, SDL_arraysize(event.text.text));
+        event.edit.windowID = keyboard->focus->id;
         posted = (SDL_PushEvent(&event) > 0);
     }
     return (posted);