2013-07-18 89 views
0

在NSTextField中:當按下up_key時,光標位置將轉到NSTextField中的文本開頭。但我需要保持光標位置。它不會開始。NSTextField保留插入位置up_key_pressed

我嘗試使用此代碼:

-(void)keyUp:(NSEvent *)theEvent 
{ 
    [[myTextField currentEditor] moveToEndOfLine:nil]; 
}  

但通過這個代碼,我可以看到光標位置去年底開始,然後轉到結束。

是什麼想法?

回答

1

我找到了解決辦法:

- (BOOL)control:(NSControl *)control textView:(NSTextView *)textView doCommandBySelector:(SEL)command 
{ 
    if([NSStringFromSelector(command) isEqualToString:@"moveUp:"]) 
    { 
     return YES; 
    } 

    return NO; 
}