src/events/SDL_keyboard.c
changeset 4434 5c64052fb476
parent 4429 faa9fc8e7f67
child 4435 e953700da4ca
equal deleted inserted replaced
4433:9fa97c6b0014 4434:5c64052fb476
   677     keyboard->focus = window;
   677     keyboard->focus = window;
   678 
   678 
   679     if (keyboard->focus) {
   679     if (keyboard->focus) {
   680         SDL_SendWindowEvent(keyboard->focus, SDL_WINDOWEVENT_FOCUS_GAINED,
   680         SDL_SendWindowEvent(keyboard->focus, SDL_WINDOWEVENT_FOCUS_GAINED,
   681                             0, 0);
   681                             0, 0);
       
   682         if (SDL_EventState(SDL_TEXTINPUT, SDL_QUERY))
       
   683             SDL_StartTextInput();
   682     }
   684     }
   683 }
   685 }
   684 
   686 
   685 int
   687 int
   686 SDL_SendKeyboardKey(int index, Uint8 state, SDL_scancode scancode)
   688 SDL_SendKeyboardKey(int index, Uint8 state, SDL_scancode scancode)
   837     }
   839     }
   838     return (posted);
   840     return (posted);
   839 }
   841 }
   840 
   842 
   841 int
   843 int
   842 SDL_SendEditingText(const char *text, int start, int length)
   844 SDL_SendEditingText(int index, const char *text, int start, int length)
   843 {
   845 {
       
   846     SDL_Keyboard *keyboard = SDL_GetKeyboard(index);
   844     int posted;
   847     int posted;
       
   848 
       
   849     if (!keyboard)
       
   850         return 0;
   845 
   851 
   846     /* Post the event, if desired */
   852     /* Post the event, if desired */
   847     posted = 0;
   853     posted = 0;
   848     if (SDL_GetEventState(SDL_TEXTEDITING) == SDL_ENABLE) {
   854     if (SDL_GetEventState(SDL_TEXTEDITING) == SDL_ENABLE) {
   849         SDL_Event event;
   855         SDL_Event event;
   850         event.edit.type = SDL_TEXTEDITING;
   856         event.edit.type = SDL_TEXTEDITING;
   851         event.edit.start = start;
   857         event.edit.start = start;
   852         event.edit.length = length;
   858         event.edit.length = length;
   853         SDL_strlcpy(event.edit.text, text, SDL_arraysize(event.text.text));
   859         SDL_strlcpy(event.edit.text, text, SDL_arraysize(event.text.text));
       
   860         event.edit.windowID = keyboard->focus->id;
   854         posted = (SDL_PushEvent(&event) > 0);
   861         posted = (SDL_PushEvent(&event) > 0);
   855     }
   862     }
   856     return (posted);
   863     return (posted);
   857 }
   864 }
   858 
   865