【发布时间】:2014-08-22 22:50:41
【问题描述】:
我正在使用 Xcode5 为 MacOSX 开发应用程序
我想控制当我在选定的 NSPopUpButton 上按 Tab 时,我创建了自己的 NSPopUpButton 子类,命名为 MyNSPopUpButton 并输入:
-(BOOL)canBecomeKeyView{
return YES;
}
现在我无法通过按 Tab 键选择我的 NSPopupButtons,但我还想控制从那里去哪里,在 NSTextFields 上我使用这种方法:
-(BOOL)control:(NSControl *)control textView:(NSTextView *)textView doCommandBySelector:(SEL)commandSelector{
NSTextField *textField = (NSTextField *) control;
if (commandSelector == @selector(insertTab:) ||
commandSelector == @selector(insertNewline:)) {
if (textField == _diaTextField) {
[self.window makeFirstResponder:_cantidadDebeTextField];
}
if (textField == _cantidadDebeTextField) {
[self.window makeFirstResponder:_cuentaDebePopupButton];
}
if (textField == _cantidadHaberTextField) {
[self.window makeFirstResponder:_descripcionAsientoTextField];
}
if (textField == _descripcionAsientoTextField) {
[self.window makeFirstResponder:_descripcionBitacoraTextField];
}
if (textField == _descripcionBitacoraTextField) {
[self.window makeFirstResponder:nil];
}
return YES;
}
return NO;
}
如您所见,我正在使用 TAB 键控制导航,我想对 NSPopUpButtons 做同样的事情,但我什至不能像使用 NSTextFields 那样设置它们的任何代表,
我知道我可以通过按正确顺序设置标签编号来做到这一点,但我会以编程方式在运行时添加更多控件
有没有办法通过代码来控制这个???
感谢支持
【问题讨论】:
标签: macos xcode5.1 nspopupbutton