Re: Handling a menu item in a modal dialog

Bill Pitcher

"While the app is in that loop, it does not respond to any other events (including mouse, keyboard, or window-close events) unless they are associated with the window. It also does not perform any tasks (such as firing timers) that are not associated with the modal run loop. In other words, this method consumes only enough CPU time to process events and dispatch them to the action methods associated with the modal window.”
Discussion: runModalForWindow

"App-Modal Dialogs
An app-modal dialog prevents the user from doing anything else in the app until the dialog is dismissed.”

Consider the
Modeless Dialogs
A modeless dialog is usually referred to as a panel. The user can continue interacting with documents and apps uninterrupted.

Bill Pitcher
Literacy Aotearoa - Dunedin

On 14/08/2018, at 12:06 PM, James Walker <list2@...> wrote:

On 8/13/18 5:04 PM, Bill Pitcher wrote:
Not sure it is possible, modal means just the controls on sheet are actioned. Normally if you’re in a sheet and you want the App to Quit you add a Button that Quits. I think you can give the button the Command-Q short cut.

If the sheet isn’t fully modal then maybe you’re better coming from the other direction and displaying it non-modally and ensuring the menu options that don’t apply are disabled. YMMV.
It's not a sheet, just a window being operated with -[NSApplication runModalForWindow:].

On 14/08/2018, at 11:51 AM, James Walker <list2@...>

I'm trying to enable the Quit menu item while a modal dialog is running, is that possible? My window controller implements the terminate: action, and has a validateMenuItem: method, but validateMenuItem: never gets called. The window is main and key, and the only thing preceding the window controller in the responder chain is the window itself, which does not respond to a "terminate:" message. I've checked that [NSApp targetForAction: @selector(terminate:)] returns my window controller. What might I be missing?

Join { to automatically receive all group messages.