src/video/cocoa/SDL_cocoakeyboard.m
changeset 4434 5c64052fb476
parent 3683 4c5ab6841fdc
child 4435 e953700da4ca
equal deleted inserted replaced
4433:9fa97c6b0014 4434:5c64052fb476
   138     }
   138     }
   139 
   139 
   140     _selectedRange = selRange;
   140     _selectedRange = selRange;
   141     _markedRange = NSMakeRange(0, [aString length]);
   141     _markedRange = NSMakeRange(0, [aString length]);
   142 
   142 
   143     SDL_SendEditingText([aString UTF8String], selRange.location, selRange.length);
   143     SDL_SendEditingText(_keyboard, [aString UTF8String],
       
   144                         selRange.location, selRange.length);
   144 
   145 
   145     DEBUG_IME(@"setMarkedText: %@, (%d, %d)", _markedText,
   146     DEBUG_IME(@"setMarkedText: %@, (%d, %d)", _markedText,
   146           selRange.location, selRange.length);
   147           selRange.location, selRange.length);
   147 }
   148 }
   148 
   149 
   630 {
   631 {
   631     SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
   632     SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
   632     NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
   633     NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
   633     NSView *parentView = [[NSApp keyWindow] contentView];
   634     NSView *parentView = [[NSApp keyWindow] contentView];
   634 
   635 
   635     data->fieldEdit = [[SDLTranslatorResponder alloc] initWithFrame:NSMakeRect(0.0, 0.0, 0.0, 0.0)];
   636     /* We only keep one field editor per process, since only the front most
       
   637      * window can receive text input events, so it make no sense to keep more
       
   638      * than one copy. When we switched to another window and requesting for
       
   639      * text input, simply remove the field editor from its superview then add
       
   640      * it to the front most window's content view */
       
   641     if (! data->fieldEdit)
       
   642         data->fieldEdit =
       
   643             [[SDLTranslatorResponder alloc] initWithFrame: NSMakeRect(0.0, 0.0, 0.0, 0.0)];
       
   644 
   636     [data->fieldEdit setKeyboard: data->keyboard];
   645     [data->fieldEdit setKeyboard: data->keyboard];
   637 
   646 
   638     if (! [[data->fieldEdit superview] isEqual: parentView])
   647     if (! [[data->fieldEdit superview] isEqual: parentView])
   639     {
   648     {
   640         // DEBUG_IME(@"add fieldEdit to window contentView");
   649         // DEBUG_IME(@"add fieldEdit to window contentView");