Using AXObserverCreate with macruby
Hello, how can I use a ruby function as an parameter to AXObserverCreate?
extern AXError AXObserverCreate ( pid_t application, AXObserverCallback callback, AXObserverRef *outObserver);
It requires an AXObserverCallback, defined as
typedef void ( *AXObserverCallback)( AXObserverRef observer, AXUIElementRef element, CFStringRef notification, void *refcon);
http://developer.apple.com/documentation/Accessibility/Reference/Accessibili... /apple%5Fref/c/tdef/AXObserverCallback I wrote a Obj.-C class (http://pastie.org/488213) to to access those functions, but how could I use ruby code as a callback? Any ideas? Ben
Hi Benjamin, On May 24, 2009, at 10:05 AM, Benjamin Mollenhauer wrote:
Hello,
how can I use a ruby function as an parameter to AXObserverCreate?
extern AXError AXObserverCreate ( pid_t application, AXObserverCallback callback, AXObserverRef *outObserver);
It requires an AXObserverCallback, defined as
typedef void ( *AXObserverCallback)( AXObserverRef observer, AXUIElementRef element, CFStringRef notification, void *refcon);
http://developer.apple.com/documentation/Accessibility/Reference/Accessibili... /apple%5Fref/c/tdef/AXObserverCallback
I wrote a Obj.-C class (http://pastie.org/488213) to to access those functions, but how could I use ruby code as a callback?
C function pointers are (as of trunk) not supported yet. But they will be supported in 0.5 in the same way RubyCocoa does (accepting Proc objects). In the meantime it's surely safer to use an intermediate Objective-C class. HTH, Laurent
participants (2)
-
Benjamin Mollenhauer
-
Laurent Sansonetti