Get basic text input support working for Cocoa gsoc2009_IME
authorJiang Jiang <gzjjgod@gmail.com>
Mon, 25 May 2009 02:42:45 +0000
branchgsoc2009_IME
changeset 3127da6cbfa5b5f2
parent 3126 395e0c7a78a3
child 3128 05d83835f41b
Get basic text input support working for Cocoa
build-scripts/showrev.sh
src/video/cocoa/SDL_cocoakeyboard.m
     1.1 --- a/build-scripts/showrev.sh	Sat May 23 22:48:40 2009 +0000
     1.2 +++ b/build-scripts/showrev.sh	Mon May 25 02:42:45 2009 +0000
     1.3 @@ -9,4 +9,7 @@
     1.4      (svnversion -c 2>/dev/null || svnversion .) | \
     1.5          sed -e 's,\([0-9]*\)[A-Z]*,\1,' \
     1.6              -e 's,[0-9]*:\([0-9]*\)[A-Z]*,\1,'
     1.7 +else
     1.8 +     cd $srcdir
     1.9 +     git svn info | grep Revision | awk '{ print $2 }'
    1.10  fi
     2.1 --- a/src/video/cocoa/SDL_cocoakeyboard.m	Sat May 23 22:48:40 2009 +0000
     2.2 +++ b/src/video/cocoa/SDL_cocoakeyboard.m	Mon May 25 02:42:45 2009 +0000
     2.3 @@ -61,7 +61,26 @@
     2.4  @end
     2.5  
     2.6  @implementation SDLTranslatorResponder
     2.7 -- (void) doCommandBySelector:(SEL) myselector {}
     2.8 +
     2.9 +- (void) insertText:(id) aString
    2.10 +{
    2.11 +    const char *str;
    2.12 +
    2.13 +    NSLog(@"insertText: %@", aString);
    2.14 +
    2.15 +    if ([aString isKindOfClass: [NSAttributedString class]])
    2.16 +        str = [[aString string] UTF8String];
    2.17 +    else
    2.18 +        str = [aString UTF8String];
    2.19 +
    2.20 +    SDL_SendKeyboardText(0, str);
    2.21 +}
    2.22 +
    2.23 +- (void) doCommandBySelector:(SEL) myselector
    2.24 +{
    2.25 +    NSLog(@"doCommandBySelector, passed down");
    2.26 +    [super doCommandBySelector: myselector];
    2.27 +}
    2.28  @end
    2.29  
    2.30  /* This is the original behavior, before support was added for 
    2.31 @@ -510,12 +529,22 @@
    2.32          }
    2.33          if (SDL_EventState(SDL_TEXTINPUT, SDL_QUERY)) {
    2.34              /* FIXME CW 2007-08-16: only send those events to the field editor for which we actually want text events, not e.g. esc or function keys. Arrow keys in particular seem to produce crashes sometimes. */
    2.35 +            NSLog(@"interpretKeyEvents");
    2.36 +            if (! [[data->fieldEdit superview] isEqual: [[event window] contentView]])
    2.37 +            {
    2.38 +                NSLog(@"add fieldEdit to window contentView");
    2.39 +                [data->fieldEdit removeFromSuperview];
    2.40 +                [[[event window] contentView] addSubview: data->fieldEdit];
    2.41 +                [[event window] makeFirstResponder: data->fieldEdit];
    2.42 +            }
    2.43              [data->fieldEdit interpretKeyEvents:[NSArray arrayWithObject:event]];
    2.44 +#if 0
    2.45              text = [[event characters] UTF8String];
    2.46              if(text && *text) {
    2.47                  SDL_SendKeyboardText(data->keyboard, text);
    2.48                  [data->fieldEdit setString:@""];
    2.49              }
    2.50 +#endif
    2.51          }
    2.52          break;
    2.53      case NSKeyUp: