ftp.nice.ch/peanuts/GeneralData/Documents/openstep/OpenStepSpec_rtf.tar.gz#/OpenStepSpec_rtf/ApplicationKit/Protocols/NSMenuActionResponder.rtf

This is NSMenuActionResponder.rtf in view mode; [Download] [Up]

paperh18648 margl-907 margr0 margt0 margb0 fi0 ri0 ql sb0 f1 fs24 Copyright f3 'e3f1 1994 by NeXT Computer, Inc.  All Rights Reserved.

s8 li100 fi0 ri1007 ql f0 b fs36 fs100 
fs36 NSMenuActionResponder
s20 fs28 (informal protocol)
pard s5 li2872 fi-2771 ri1007 ql tx2872 f1 b0 fs28 fs48 
fs28 f0 b fs24 Category Of:tab b0 fs28 f1 NSObject
fs20 
fs28 s11 f0 b fs24 Declared In:tab b0 fs28 f1 AppKit/NSMenu.h 
fs20 
fs28 pard s27 li100 fi0 ri1007 ql f0 b fs28 fs20 
fs28 Protocol Description
fs14 
fs28 pard s2 li477 fi0 ri1007 ql tx2494 tx2872 tx3250 f1 b0 fs2 
fs28 This informal protocol allows your application to update the enabled or disabled status of an NSMenuCell. It declares only one method, b validateCell:b0 . By default, every time a user event occurs, NSMenu automatically enables and disables each visible menu cell based on criteria described later in this specification. Implement b validateCell:b0  in cases where you want to override NSMenu'27s default enabling scheme. This is described in more detail later.
fs16 
fs28 There are two ways that NSMenuCells can be enabled or disabled: Explicitly, by sending the b setEnabled:b0  message, or automatically, as described below. NSMenuCells are updated automatically unless you send the message b setAutoenablesItems:NOb0  to the NSMenu object. You should never mix the two. That is, never use b setEnabled:b0  unless you have disabled the automatic updating. 
fs16 
fs28 pard s26 li477 fi0 ri1007 ql f0 b fs24 fs4 
fs24 Automatic Updating of NSMenuCells
pard s2 li477 fi0 ri1007 ql tx2494 tx2872 tx3250 f1 b0 fs28 fs16 
fs28 Whenever a user event occurs, the NSMenu object updates the status of every visible menu cell. To update the status of a menu cell, NSMenu tries to find the object that responds to the NSMenuCell'27s action message. It searches the following objects in the following order until it finds one that responds to the action message. 
fs16 
fs28 pard s4 li1231 fi-376 ri1007 ql tx1231 tx2872 tx3250 'b7tab the NSMenuCell'27s target
fs16 
fs28 'b7tab the key window'27s first responder
fs16 
fs28 'b7tab the key window'27s delegate
fs16 
fs28 'b7tab the main window'27s first responder
fs16 
fs28 'b7tab the main window'27s delegate
fs16 
fs28 'b7tab the NSApplication object
fs16 
fs28 'b7tab the NSApplication'27s delegate
fs16 
fs28 'b7tab the NSMenu'27s delegate
fs16 
fs28 pard s2 li477 fi0 ri1007 ql tx2494 tx2872 tx3250 If none of these objects responds to the action message, the menu cell is disabled. If NSMenu finds an object that responds to the action message, it then checks to see if that object responds to the b validateCell:b0  message (the method defined in this informal protocol). If b validateCell:b0  is not implemented in that object, the menu cell is enabled. If it is implemented, the return value of b validateCell:b0  indicates whether the menu cell should be enabled or disabled.
fs16 
fs28 For example, the NSText object implements the b copy:b0  method. If your application has a Copy menu cell that sends the b copy:b0  action message to the first responder, that menu cell is automatically enabled any time an NSText object is the first responder of the key or main window. If you have an object that might become the first responder and that object could allow users to select something that they aren'27t allowed to copy, you can implement the b validateCell:b0  method in that object. b validateCell:b0  can return NO if the forbidden items are selected and YES if they aren'27t. By implementing b validateCell:b0 , you can have the Copy menu item disabled even though its target object implements the b copy:b0  method. If instead your object i neveri0  permits copying, then you would simply not implement b copy:b0  in that object, and the cell would be disabled automatically whenever the object is first responder.
fs16 
fs28 If you send a b setEnabled:b0  message to enable or disable a menu cell when the automatic updating is turned on, other objects might reverse what you have done after another user event occurs. Using b setEnabled:b0 , you can never be sure that a menu cell is enabled or disabled or will remain that way. If your application must use b setEnabled:b0 , you must turn off the automatic enabling of menu cells (by sending b setAutoEnablesItems:NOb0  to NSMenu) in order to get predictable results.
fs16 
fs28 pard s27 li100 fi0 ri1007 ql f0 b fs24 
fs28 Updating NSMenuCells
fs14 
fs28 pard s14 li7029 fi-6552 ri1007 ql tx6652 tx7030 f1 b0 fs2 
fs28 fi-6552 {f3 -} (BOOL)b validateCell:b0 (id)i aCelltab i0 Implemented to override the default action of updating an NSMenuCell. Return YES to enable the NSMenuCell, NO to disable it.
}

These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.