PDA

View Full Version : kAEOpenDocuments handling


mlfarrell
2006.07.27, 09:08 PM
I'm trying to handle the kAEOpenDocuments message in my gtk program but I suspect X11 is intercepting the message. Is there anything I can do about this?


static OSErr open_documents_ae_handler(const AppleEvent *apple_event, AppleEvent *reply, SInt32 ref_con)
{
//never gets called on document double click
//program does get launched though if it wasn't running

app.message_box("Something happened!");
return noErr;
}

AEEventHandlerUPP od_handler = NewAEEventHandlerUPP(open_documents_ae_handler);
if(AEInstallEventHandler(kCoreEventClass, kAEOpenDocuments, od_handler, NULL, false) != noErr)
cerr << "Error installing apple event handler for open documents!" << endl;
DisposeAEEventHandlerUPP(od_handler);

OneSadCookie
2006.07.27, 09:29 PM
X11 applications don't receive either Carbon or Cocoa events.

You need to use GTK's native mechanism for this, whatever that might be, and double-click your documents from Nautilus rather than the Finder :)

OneSadCookie
2006.07.27, 09:38 PM
Another option might be to use the native Mac OS X GTK+ (still rather experimental by the looks): http://developer.imendio.com/wiki/Gtk_Mac_OS_X which doesn't rely on X11, and therefore delivers the standard Cocoa events direct to your application.