Of modal windows and nil-targeted menu actions

  • It has been explained how to make non-nil targeted menus autoenable
    properly in the presence of a modal window:
    http://www.cocoabuilder.com/archive/message/cocoa/2004/10/7/119051

    And the documentation now gives a full list of all the objects one
    might find in the responder chain:
    http://developer.apple.com/documentation/Cocoa/Conceptual/
    EventOverview/EventArchitecture/chapter_2_section_6.html

    What isn't explained is that nil-targeted menus climb different
    responder chains depending on the class of the modal window:

    NSWindow:
    Included: the window itself, window's delegate, window's
    NSWindowController, application object, application delegate
    Excluded: nothing*

    NSPanel:
    Included: the key window itself, key window's delegate, key window's
    NSWindowController
    Excluded: main window, main window delegate, main window's
    NSWindowController, application object, application delegate

    * Even when an NSWindow is run modal, it still becomes both key and
    main. So only one window's responder chain shows up here.

    NSPanel's behavior is generally more desirable; I got to looking at
    this because I didn't want my application delegate responding when
    there was a modal window up. Lastly, beware that -[NSApplication
    targetForAction:to:from:] traverses the responder chain as
    documented, without consideration of modality.

    Allen
previous month december 2007 next month
MTWTFSS
          1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31            
Go to today