Re: Running event loop while showing non-standard popup
Re: Running event loop while showing non-standard popup
- Subject: Re: Running event loop while showing non-standard popup
- From: Kyle Sluder <email@hidden>
- Date: Tue, 21 May 2013 08:11:45 -0700
On May 21, 2013, at 6:51 AM, Steve Mills <email@hidden> wrote:
> On May 21, 2013, at 01:58:00, Kyle Sluder <email@hidden> wrote:
>
>> The docs for +[NSEvent addLocalMonitor…] state that it does not work with nested event loops like the kind -[NSApplication runModalForWindow:] uses.
>
> The docs don't specifically say runModalForWindow, which leads the reader to assume it would work. Docs should always spell out exactly when something won't work if the vendor already knows of such things.
It quite clearly says it will not work with nested event loops. +runModalForWindow: is but one way to run a nested event loop. It's not the job of every method's documentation to teach you how the entire framework works.
>
> So then, what's the next thing to try? Seems like the next best thing is to subclass NSApplication, override sendEvent, and add special code to it just to handle this one small thing in a huge complex app.
You could try it, but +runModalForWindow might not invoke -sendEvent: to dispatch the events it pulls off the event queue within its nested runloop invocation.
> Or is there a way to create a new "regular" event loop?
Let's back up to your original question. Why do you need to run a runloop at all? NSPopupButtonCell will do that for you, and it will correctly handle the case where the user clicks outside the menu to dismiss.
Look up -performClickWithFrame:inView:.
--Kyle Sluder
_______________________________________________
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