• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Cocoa window in Carbon app and [NSApp postEvent]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Cocoa window in Carbon app and [NSApp postEvent]


  • Subject: Re: Cocoa window in Carbon app and [NSApp postEvent]
  • From: Ken Ferry <email@hidden>
  • Date: Thu, 13 Aug 2009 22:43:47 -0700

Hi,
It sounds to me like you are interested in
-[NSObject performSelectorOnMainThread:withObject:waitUntilDone:modes:].

-Ken

On Thu, Aug 13, 2009 at 12:38 PM, Frederik Slijkerman <
email@hidden> wrote:

> 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 (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
>
_______________________________________________

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

  • Follow-Ups:
    • Re: Cocoa window in Carbon app and [NSApp postEvent]
      • From: Frederik Slijkerman <email@hidden>
References: 
 >Cocoa window in Carbon app and [NSApp postEvent] (From: Frederik Slijkerman <email@hidden>)

  • Prev by Date: Re: File's owner, outlets and methods
  • Next by Date: [Moderator] Re: scroll view is now disabled after switching to snowleopard
  • Previous by thread: Cocoa window in Carbon app and [NSApp postEvent]
  • Next by thread: Re: Cocoa window in Carbon app and [NSApp postEvent]
  • Index(es):
    • Date
    • Thread