NSTextField重复输入

时间:2017-01-19 20:10:45

标签: objective-c nstextfield

我正在obj-c中构建一个安装程序插件,该插件在NSTextFields中获取某些输入值,并使用controlTextDidChange执行操作,该操作在我的机器(Sierra)上的安装程序中完全正常。< / p>

如果我将安装程序复制到另一台机器(El Capitan),每次我输入'e'(或其他)进入NSTextField时,它会自动输入另一个'e',因此我有2个重复的字符(和{{ 1}}运行2x)。退格只删除一个。

为什么会出现这种情况?

修改:这是我的controlTextDidChange

controlTextDidChange

我有两个- (void)controlTextDidChange:(NSNotification *)obj{ NSTextField *textField = [obj object]; /*portField triggered, only allow non empty numeric input*/ if (textField == _portField){ NSCharacterSet *charSet = [NSCharacterSet characterSetWithCharactersInString:@"0123456789"]; for (int i = 0; i < [textField.stringValue length]; i++) { unichar c = [textField.stringValue characterAtIndex:i]; /*found none numeric, show last valid and do not proceed to write*/ if (![charSet characterIsMember:c]) { if (i==0){ _portField.stringValue = @""; } else { _portField.stringValue = lastValidPort.stringValue; } return; } } } //[self alert:@"call" :@"text change"]; [self toggleContinueButton]; NSNumber *portValue = [self stringToInt:_portField.stringValue]; lastValidPort = portValue; NSDictionary *update = [self newValuesInDict]; [self writeToCsv:update]; } 来调用它,并且它们都表现出相同的行为。

0 个答案:

没有答案
相关问题