0

I'm trying to use controlTextDidChange() in a NStextField with currency formatter under OS X to hide a labelField when user modify the content of the NSTextField. Unfortunately when I try to use it, the NStextFiedl accepts only a change and then don't permits other changes. I thing this is a consequence of the interaction of the currency formatter and the code I put in controlTextDidChange(). Anyone can suggest a solution?

    override func controlTextDidChange(notification: NSNotification) {
   // print("Text changed: \(totalField.stringValue)") // this blocks entering more than a digit in the NStextField
    // NSBeep() // this don't block entering any number of digits in the NStextField
}
Cue
  • 2,952
  • 3
  • 33
  • 54
  • I suspect this is because `stringValue` implicitly calls `validateEditing`. You might want to work with the field editor directly. But what exactly are you trying to do? – jtbandes Mar 29 '16 at 08:58
  • I jtbandes, I have a window with a NStextField, a Button and a textLabel. The NStextField is used to enter a sum which is then computed (when user press a button) and the result put in a textLabel, so what I'm trying to do is to hide the result textLabel when the user changes the content of the NStextField. This because when the content of the NStextField is changed, then the textLabel of the result displays a result outdated (until user presses the button again). – Cue Mar 29 '16 at 15:07
  • Do you need `controlTextDidChange` or will `control:textShouldBeginEditing:` do? – Willeke Mar 30 '16 at 11:09
  • I Willeke 7, actually I have just the need to hide the Results textLabel when the user changes the value of the NStextField, so maybe an alternative way could fit my needs. Being a beginner I was trying with controlTextDidChange() but now I'm not sure it's the right choice. – Cue Mar 30 '16 at 19:05

0 Answers0