1

cocoa Key Event Handling docs を読みました。次のようなコード スニペットの例を取得します。問題は、英語以外の入力方法 (中国語など) を変更した場合です。コード スニペットは機能しません。単一のアルファベット文字は返されますが、Unicode の漢字は返されません。提案またはドキュメントの一部が欠けていますか?

- (void)keyDown:(NSEvent *)theEvent
{
    [self interpretKeyEvents:[NSArray arrayWithObject:theEvent]];
}

// The following action methods are declared in NSResponder.h
- (void)insertTab:(id)sender
{
    if ([[self window] firstResponder] == self)
    {
        [[self window] selectNextKeyView:self];
    }
}


- (void)insertBacktab:(id)sender
{
    if ([[self window] firstResponder] == self)
    {
        [[self window] selectPreviousKeyView:self];
    }
}

- (void)insertText:(id)string
{
    [super insertText:string];  // have superclass insert it
}
4

2 に答える 2

0

デフォルトの実装 ( [NSEvent characters]? charactersIgnoringModifiers?) が機能しない場合は、イベントの を介して値にアクセスしてから、 の@property CGEventようなものを使用して目的の結果が得られるかどうかを確認できますCGEventKeyboardGetUnicodeString

于 2012-08-20T07:43:05.870 に答える