Tuesday, January 22, 2013

Key Events with Class Cocoa Controls in Real Studio (Xojo)


The coolest part of using Real Studio is access to all the controls for each platform. Some of these controls are not built-in by default but are still available to use by using declares or Plugins (Like Monkey Bread Software, Complete Plugin or the Mac OSLib (free by the way.) to name an few.). Whatever you choose its up to you.

This however can present some interesting coding challenges to add support for certain events that are available to similar built in controls. Such as the text field keydown event can use an return key to preform an action. There is no keydown event however for an non built-in control, instead one needs to get creative and figure another way around this.

Lucky enough anything is possible by code. This is an simple look at getting an NSSearchField on OSX to search on clicking the Return or Enter key press. This without an event that supports keydown or keyup events.

The reason for this video is there no documentation, I could find to tell us how to do such. It was hours of trial and error to figuring it out. However I believe such information should be shared.

Here an simple video to show how this is done. I showing this off using OSX based controls, because I currently on mac. But should be similar on other platforms.


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.