comparison src/video/cocoa/SDL_cocoakeyboard.m @ 4434:5c64052fb476

changeset: 4433:25667ea797fa tag: tip user: Jiang Jiang <gzjjgod@gmail.com> date: Thu Apr 15 12:01:46 2010 +0800 summary: Add windowID to text editing event
author Sam Lantinga <slouken@libsdl.org>
date Thu, 15 Apr 2010 22:14:26 -0700
parents 4c5ab6841fdc
children e953700da4ca
comparison
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");