Wednesday, January 16, 2013

Mask Numbers only with text field in Cocoa

I been finding out many things that worked in Mac Carbon builds do not actually work the same in Cocoa builds. Lucky enough there are work arounds to fix many of these items.


In Carbon if we wanted to limit numbers in an text field we could simply do this in its open event. Using an mask like such:

me.text="9999"

That mask would limit numbers only and up to 4 numbers max. However masks do not work in Cocoa at all so we need to address this in an keydown event. This quick you tube video we made shows the simple and fast work around, witch does work on all platforms, Including Cocoa builds.




 I hope this helps out, moving from carbon to fully support Cocoa. As its little things like this that can make the task of converting Older Carbon apps to Cocoa not as simple as just an recompile.

No comments:

Post a Comment