RE: Getting Carbon EventRef from cocoa NSEvent
RE: Getting Carbon EventRef from cocoa NSEvent
- Subject: RE: Getting Carbon EventRef from cocoa NSEvent
- From: Jesper Storm Bache <email@hidden>
- Date: Thu, 23 Oct 2008 14:44:07 -0700
- Acceptlanguage: en-US
- Thread-topic: Getting Carbon EventRef from cocoa NSEvent
If you look in NSEvent.h you will see :
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
/* -eventRef and +eventWithEventRef: are valid for all events */
/* -eventRef returns an EventRef corresponding to the NSEvent. The EventRef is retained by the NSEvent, so will be valid as long as the NSEvent is valid, and will be released when the NSEvent is freed. You can use RetainEvent to extend the lifetime of the EventRef, with a corresponding ReleaseEvent when you are done with it. If there is no EventRef corresponding to the NSEvent, -eventRef will return NULL.
*/
- (const void * /* EventRef */)eventRef;
...
I.e. eventRef is only supported by Apple on 10.5 and newer.
Jesper
________________________________________
From: carbon-dev-bounces+jsbache=email@hidden [carbon-dev-bounces+jsbache=email@hidden] On Behalf Of Rangaswamy C T [email@hidden]
Sent: Thursday, October 23, 2008 2:42 PM
To: email@hidden; email@hidden
Subject: Getting Carbon EventRef from cocoa NSEvent
Hi All,
For some requirement in my product, I have embedded my Carbon window inside Cocoa window using addChildWindow method.
For getting my carbon window UI (keyboard and mouse) events working, I had to watch cocoa events for NSWindow of Carbon window and then redispatch carbon eventRef’s to Carbon window using SendEventToEventTarget API.
So while converting Cocoa event to carbon events, I used the following piece of code
- (void)keyDown:(NSEvent *)theEvent
{
OSStatus status; //1
EventRef carbonEvnt; //2
carbonEvnt = (EventRef) [theEvent eventRef]; //3
}
But the above NSEvent method eventRef is crashing (at 3) on Tiger. But on Leopard it works fine.
Am I doing anything wrong here?
Thanks
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden