Minor cleanup on Jiang's patch
This commit is contained in:
parent
f9a8341561
commit
fc440f959f
3 changed files with 13 additions and 6 deletions
|
@ -139,6 +139,7 @@ typedef struct SDL_TextEditingEvent
|
|||
{
|
||||
Uint32 type; /**< ::SDL_TEXTEDITING */
|
||||
Uint32 windowID; /**< The window with keyboard focus, if any */
|
||||
Uint8 which; /**< The keyboard device index */
|
||||
char text[SDL_TEXTEDITINGEVENT_TEXT_SIZE]; /**< The editing text */
|
||||
int start; /**< The start cursor of selected editing text */
|
||||
int length; /**< The length of selected editing text */
|
||||
|
|
|
@ -679,8 +679,10 @@ SDL_SetKeyboardFocus(int index, SDL_Window * window)
|
|||
if (keyboard->focus) {
|
||||
SDL_SendWindowEvent(keyboard->focus, SDL_WINDOWEVENT_FOCUS_GAINED,
|
||||
0, 0);
|
||||
if (SDL_EventState(SDL_TEXTINPUT, SDL_QUERY))
|
||||
|
||||
if (SDL_EventState(SDL_TEXTINPUT, SDL_QUERY)) {
|
||||
SDL_StartTextInput();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -832,6 +834,7 @@ SDL_SendKeyboardText(int index, const char *text)
|
|||
if (SDL_GetEventState(SDL_TEXTINPUT) == SDL_ENABLE) {
|
||||
SDL_Event event;
|
||||
event.text.type = SDL_TEXTINPUT;
|
||||
event.text.windowID = keyboard->focus ? keyboard->focus->id : 0;
|
||||
event.text.which = (Uint8) index;
|
||||
SDL_strlcpy(event.text.text, text, SDL_arraysize(event.text.text));
|
||||
event.text.windowID = keyboard->focus->id;
|
||||
|
@ -846,18 +849,20 @@ SDL_SendEditingText(int index, const char *text, int start, int length)
|
|||
SDL_Keyboard *keyboard = SDL_GetKeyboard(index);
|
||||
int posted;
|
||||
|
||||
if (!keyboard)
|
||||
if (!keyboard) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Post the event, if desired */
|
||||
posted = 0;
|
||||
if (SDL_GetEventState(SDL_TEXTEDITING) == SDL_ENABLE) {
|
||||
SDL_Event event;
|
||||
event.edit.type = SDL_TEXTEDITING;
|
||||
event.edit.windowID = keyboard->focus ? keyboard->focus->id : 0;
|
||||
event.text.which = (Uint8) index;
|
||||
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;
|
||||
SDL_strlcpy(event.edit.text, text, SDL_arraysize(event.edit.text));
|
||||
posted = (SDL_PushEvent(&event) > 0);
|
||||
}
|
||||
return (posted);
|
||||
|
|
|
@ -638,13 +638,14 @@ Cocoa_StartTextInput(_THIS)
|
|||
* than one copy. When we switched to another window and requesting for
|
||||
* text input, simply remove the field editor from its superview then add
|
||||
* it to the front most window's content view */
|
||||
if (! data->fieldEdit)
|
||||
if (!data->fieldEdit) {
|
||||
data->fieldEdit =
|
||||
[[SDLTranslatorResponder alloc] initWithFrame: NSMakeRect(0.0, 0.0, 0.0, 0.0)];
|
||||
}
|
||||
|
||||
[data->fieldEdit setKeyboard: data->keyboard];
|
||||
|
||||
if (! [[data->fieldEdit superview] isEqual: parentView])
|
||||
if (![[data->fieldEdit superview] isEqual: parentView])
|
||||
{
|
||||
// DEBUG_IME(@"add fieldEdit to window contentView");
|
||||
[data->fieldEdit removeFromSuperview];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue