Mercurial > sdl-ios-xcode
comparison src/events/SDL_keyboard.c @ 4435:e953700da4ca
Minor cleanup on Jiang's patch
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Thu, 15 Apr 2010 22:27:01 -0700 |
parents | 5c64052fb476 |
children | 25e45611fa3d |
comparison
equal
deleted
inserted
replaced
4434:5c64052fb476 | 4435:e953700da4ca |
---|---|
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)) | 682 |
683 if (SDL_EventState(SDL_TEXTINPUT, SDL_QUERY)) { | |
683 SDL_StartTextInput(); | 684 SDL_StartTextInput(); |
685 } | |
684 } | 686 } |
685 } | 687 } |
686 | 688 |
687 int | 689 int |
688 SDL_SendKeyboardKey(int index, Uint8 state, SDL_scancode scancode) | 690 SDL_SendKeyboardKey(int index, Uint8 state, SDL_scancode scancode) |
830 /* Post the event, if desired */ | 832 /* Post the event, if desired */ |
831 posted = 0; | 833 posted = 0; |
832 if (SDL_GetEventState(SDL_TEXTINPUT) == SDL_ENABLE) { | 834 if (SDL_GetEventState(SDL_TEXTINPUT) == SDL_ENABLE) { |
833 SDL_Event event; | 835 SDL_Event event; |
834 event.text.type = SDL_TEXTINPUT; | 836 event.text.type = SDL_TEXTINPUT; |
837 event.text.windowID = keyboard->focus ? keyboard->focus->id : 0; | |
835 event.text.which = (Uint8) index; | 838 event.text.which = (Uint8) index; |
836 SDL_strlcpy(event.text.text, text, SDL_arraysize(event.text.text)); | 839 SDL_strlcpy(event.text.text, text, SDL_arraysize(event.text.text)); |
837 event.text.windowID = keyboard->focus->id; | 840 event.text.windowID = keyboard->focus->id; |
838 posted = (SDL_PushEvent(&event) > 0); | 841 posted = (SDL_PushEvent(&event) > 0); |
839 } | 842 } |
844 SDL_SendEditingText(int index, const char *text, int start, int length) | 847 SDL_SendEditingText(int index, const char *text, int start, int length) |
845 { | 848 { |
846 SDL_Keyboard *keyboard = SDL_GetKeyboard(index); | 849 SDL_Keyboard *keyboard = SDL_GetKeyboard(index); |
847 int posted; | 850 int posted; |
848 | 851 |
849 if (!keyboard) | 852 if (!keyboard) { |
850 return 0; | 853 return 0; |
854 } | |
851 | 855 |
852 /* Post the event, if desired */ | 856 /* Post the event, if desired */ |
853 posted = 0; | 857 posted = 0; |
854 if (SDL_GetEventState(SDL_TEXTEDITING) == SDL_ENABLE) { | 858 if (SDL_GetEventState(SDL_TEXTEDITING) == SDL_ENABLE) { |
855 SDL_Event event; | 859 SDL_Event event; |
856 event.edit.type = SDL_TEXTEDITING; | 860 event.edit.type = SDL_TEXTEDITING; |
861 event.edit.windowID = keyboard->focus ? keyboard->focus->id : 0; | |
862 event.text.which = (Uint8) index; | |
857 event.edit.start = start; | 863 event.edit.start = start; |
858 event.edit.length = length; | 864 event.edit.length = length; |
859 SDL_strlcpy(event.edit.text, text, SDL_arraysize(event.text.text)); | 865 SDL_strlcpy(event.edit.text, text, SDL_arraysize(event.edit.text)); |
860 event.edit.windowID = keyboard->focus->id; | |
861 posted = (SDL_PushEvent(&event) > 0); | 866 posted = (SDL_PushEvent(&event) > 0); |
862 } | 867 } |
863 return (posted); | 868 return (posted); |
864 } | 869 } |
865 | 870 |