src/video/cocoa/SDL_cocoakeyboard.m
changeset 4434 5c64052fb476
parent 3683 4c5ab6841fdc
child 4435 e953700da4ca
     1.1 --- a/src/video/cocoa/SDL_cocoakeyboard.m	Thu Apr 15 21:27:32 2010 -0700
     1.2 +++ b/src/video/cocoa/SDL_cocoakeyboard.m	Thu Apr 15 22:14:26 2010 -0700
     1.3 @@ -140,7 +140,8 @@
     1.4      _selectedRange = selRange;
     1.5      _markedRange = NSMakeRange(0, [aString length]);
     1.6  
     1.7 -    SDL_SendEditingText([aString UTF8String], selRange.location, selRange.length);
     1.8 +    SDL_SendEditingText(_keyboard, [aString UTF8String],
     1.9 +                        selRange.location, selRange.length);
    1.10  
    1.11      DEBUG_IME(@"setMarkedText: %@, (%d, %d)", _markedText,
    1.12            selRange.location, selRange.length);
    1.13 @@ -632,7 +633,15 @@
    1.14      NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
    1.15      NSView *parentView = [[NSApp keyWindow] contentView];
    1.16  
    1.17 -    data->fieldEdit = [[SDLTranslatorResponder alloc] initWithFrame:NSMakeRect(0.0, 0.0, 0.0, 0.0)];
    1.18 +    /* We only keep one field editor per process, since only the front most
    1.19 +     * window can receive text input events, so it make no sense to keep more
    1.20 +     * than one copy. When we switched to another window and requesting for
    1.21 +     * text input, simply remove the field editor from its superview then add
    1.22 +     * it to the front most window's content view */
    1.23 +    if (! data->fieldEdit)
    1.24 +        data->fieldEdit =
    1.25 +            [[SDLTranslatorResponder alloc] initWithFrame: NSMakeRect(0.0, 0.0, 0.0, 0.0)];
    1.26 +
    1.27      [data->fieldEdit setKeyboard: data->keyboard];
    1.28  
    1.29      if (! [[data->fieldEdit superview] isEqual: parentView])