Hi,

I'm working on a Photoshop plugin that uses a Cocoa UI, while of course Photoshop is still Carbon currently. The plugin runs as a modal window pretty much all the time.

Now I've run into a problem: when I post a custom event to the main event queue using [NSApp postEvent], it is never processed. As far as I can tell, this is because [NSApp runModalForWindow] calls into Carbon to actually run the modal window, and while Carbon does handle mouse, keyboard and timer messages fine (by sending them directly to the window involved), it apparently doesn't know anything about any Cocoa events that are waiting in the main event queue.

Does this sound familiar to anyone? Is there any way I can work around this?

This is the code I use to post the event:

  NSEvent *event = [NSEvent otherEventWithType:NSApplicationDefined
    location:NSZeroPoint modifierFlags:0 timestamp:0 windowNumber:0
    context:0 subtype:0 data1:reinterpret_cast<NSInteger>(h)
    data2:reinterpret_cast<NSInteger>(data)];
  [NSApp postEvent:event atStart:NO];

I've thought about replacing postEvent with a timer that would fire immediately, but it looks like this wouldn't work from a different thread, as timers work directly with NSRunLoop and NSRunLoop has a stern warning regarding thread safety...

So basically what I'm looking for is a thread-safe way to add an event to the main event queue, in such a way that it will be processed even when a modal window is running, this all in a Carbon application.

Thanks in advance!

Best regards,
Frederik Slijkerman
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to