如何使Tab键移动焦点从NSTextView? [英] How can I make the Tab key move focus out of a NSTextView?
本文介绍了如何使Tab键移动焦点从NSTextView?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用NSTextView来允许多行输入。然而,由于我的应用程序的性质,当他们按TAB时,用户将更加舒服地移动到下一个输入元素。
I'm using an NSTextView to allow multi-line input. However, due to the nature of my app, users will be more comfortable moving to the next input element when they press TAB.
如何使TAB退出NSTextView,同时保持Enter键的换行行为
How can I make TAB exit the NSTextView, while keeping the newline behaviour of the Enter key?
推荐答案
您可以实现 -textView:doCommandBySelector: / code>在您的文本视图的委托:
You could implement -textView:doCommandBySelector:
in your text view's delegate:
- (BOOL)textView:(NSTextView *)aTextView doCommandBySelector:(SEL)aSelector {
if (aSelector == @selector(insertTab:)) {
[[aTextView window] selectNextKeyView:nil];
return YES;
}
return NO;
}
查看 http://developer.apple.com/documentation/Cocoa/Reference/NSTextViewDelegate_Protocol
这篇关于如何使Tab键移动焦点从NSTextView?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文