Search code examples
objective-ceventstextboxkeystroke

Objective-C/Xcode - password checking as user types


I would love to do something to reward the user visually when they match two text fields as they type. This is jQuery-esque, and I'm not sure if it's possible in Objective-C/Xcode. The key here is "AS THEY TYPE". Some web-based user account setup forms show a green checkbox when the password/confirmPassword (mainly because of the secure field formatting •••••) or email/confirmEmail form fields match or turn into a red "X" if the passwords lose their match.

Is there anything similar to an onKeystroke event in Objective-C/Xcode?

I'm willing to research and learn this. I just don't know how to correctly reference this type of functionality.


Solution

  • Everything you want is in here https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/EventOverview/HandlingKeyEvents/HandlingKeyEvents.html#//apple_ref/doc/uid/10000060i-CH7-SW1

    What you're looking for is to implement the following in your text view and buffer the keystrokes and compare them with your text field.

    - (void)keyUp:(NSEvent *)theEvent