FredKiefer@gmx.de
)khelekir@encomix.es
)mhanni@sprintmail.com
)far@ix.netcom.com
)ovidiu@net-community.com
)Copyright: (C) 1999 Free Software Foundation, Inc.
- Declared in:
- AppKit/NSMenu.h
- Conforms to:
- NSCoding
- NSCopying
Standards:
- MacOS-X
- OpenStep
- GNUstep
Menus provide the user with a list of actions and/or submenus. Submenus themselves are full fledged menus and so a heirarchical structure of appears.
Every application has one special menu, the so called Application menu. This menu is always visible on the screen when the application is active. This menu normally contains items like, info, services, print, hide and quit.
After the info item normally some submenus follow containing the application specific actions.
On GNUstep the content of the menu is stacked vertically as oppossed to the Windows and Mac world, where they are stacked horizontally. Also because the menus are not part of any normal window they can be dragged around opened and closed independend of the application windows.
This can lead to a few menus being open simultanuously. The collection of open menus is remembered, when the program is started again, all the torn off menus aka detached menus, are displayed at their last known position.
The menu behaviour is richer than in most other environments and bear some explanation. This explanation is aimed at users of Menus but more so at the developer of custom menus.
It is important to note that it is impossible to click in transient menus.
If the submenu is a detached menu, the transient version of the submenu will be shown
Description forthcoming.
Description forthcoming.
Description forthcoming.
Description forthcoming.
Description forthcoming.
Returns the menu that is attached to this menu.
If two instances of this menu are visible, return the attached window of the transient version of this menu.
If no menu is attached return nil
.
Description forthcoming.
Description forthcoming.
Description forthcoming.
Description forthcoming.
Description forthcoming.
Description forthcoming.
Description forthcoming.
Description forthcoming.
Description forthcoming.
Description forthcoming.
Description forthcoming.
Returns if this menu is attached to its supermenu,
return nil
if it does not have a parent
menu.
If two instances of this menu are visible, return the outcome of the check for the transient version of the menu.
Look for the semantics in the header. Note that this implementation works because there are... cases:
If there are two instances of this menu visible, return
NO
. Otherwise, return YES
if we are a detached menu and visible.
Returns an array containing all menu items in this menu.
Description forthcoming.
Description forthcoming.
Description forthcoming.
Description forthcoming.
Returns the position where submenu will be displayed when it will be displayed as an attached menu of this menu. The result is undefined when aSubmenu is not actually a submenu of this menu.
Description forthcoming.
Return the NSView that is used for drawing the menu. It is the view set with [NSMenu -setMenuRepresentation:] and therefore it should be safe to assume it is an NSView implementing the NSMenuView protocol.
Description forthcoming.
Description forthcoming.
Description forthcoming.
Description forthcoming.
Description forthcoming.
Description forthcoming.
Description forthcoming.
Set the View that should be used to display the menu.
The default is NSMenuView, but a user can supply its own NSView object as long as it
Description forthcoming.
Set the supermenu of this menu. TODO: add explanation if this will change remove this menu from the old supermenu or if it does not.
Change the title of the menu.
Description forthcoming.
Description forthcoming.
Returns the supermenu of this menu. Return
nil
if this is the application menu.
Returns the current title.
Description forthcoming.
- Declared in:
- AppKit/NSMenu.h
Standards:
- NotOpenStep
- NotMacOS-X
- GNUstep
This interface exist contains methods that are meant for the NSMenuView. If you write your own implementation of the NSMenuView interface you can use these methods to popup other menus or close them.
Method summaryWarning the underscore at the start of the name of this method indicates that it is private, for internal use only, and you should not use the method in your code.
Warning the underscore at the start of the name of this method indicates that it is private, for internal use only, and you should not use the method in your code.
Remove the window from the screen. This method can/should be used by the menurepresentation to remove a submenu from the screen.
Remove the transient version of the window from the screen. This method is used by NSMenuView implementations that need to open/close transient menus.
Show menu on the screen. This method can/should be used by the menurepresentation to display a submenu on the screen.
Display the transient version of the menu.
Description forthcoming.
Returns YES
if there is a transient
version of this menu displayed on the screen.
Set the frame origin of the receiver to aPoint. If a submenu of the receiver is attached. The frame origin of the submenu is set appropriately.
Positions the menu according to the standard user defaults. If the position is not found in the defaults revert to positioning the window in the upper left corner.
When the flag is YES
this
method will detach the receiver from its parent and
update the menurepresentation so it will display a
close button if appropriate. If the flag
is NO
this method will update the
menurepresentation so it will be able to
remove the close button if needed. Note that it will
not reattach to its parent menu.
Description forthcoming.
Returns the window in which this menu is displayed. If there is a transient version it will return the window in which the transient version is displayed. If the Menu is not displayed at all the result is meaningless.
- Declared in:
- AppKit/NSMenu.h
Standards:
- NotOpenStep
- NotMacOS-X
- GNUstep
Description forthcoming.
Method summaryDescription forthcoming.
- Declared in:
- AppKit/NSMenu.h
Standards:
- MacOS-X
- OpenStep
- GNUstep
Specifies the protocol to which an object must confirm if it is to be used to validate menu items (in order to implement automatic enabling and disabling of menu items).
Method summary
The receiver should return YES
if the
menuItem is valid... and should be
enabled in the menu, NO
if it is
invalid and the user should not be able to select
it.
This method is invoked automatically to determine whether menu items should be enabled or disabled automatically whenever [NSMenu -update] is invoked (usually by the applications event loop).
- Declared in:
- AppKit/NSMenu.h
Standards:
- MacOS-X
- OpenStep
- GNUstep
Description forthcoming.
Method summaryThis should ensure that if there is an attached submenu this submenu will be detached. Detaching means that this particular menu representation should be removed from the screen. It should implement a deep detach, that is, all attached submenus of this menu should also be detached.
Returns the currently highlighted item. Returns -1 if no item is highlighted.
Method used by NSMenuItemCell to draw itself correctly and nicely lined up with the other menu items
Methos used by NSMenuItemCell to draw itself correctly and nicely lined up with the other menu items.
Methos used by NSMenuItemCell to draw itself correctly and nicely lined up with the other menu items.
Used by NSItemCell to...
Used by the NSMenu to determine where to position a submenu.
Description forthcoming.
Set the currently highlighted item. This is used by the NSMenu class to restore the selected item when it is temporary set to another item. This happens when both the regular version and the transient version are on the screen. A value of -1 means that no item will be highlighted.
Set the menu that this view object will be drawing. This method will NOT retain the menu. In normal usage an instance of NSMenu will use this method to supply the NSMenuView with reference to itself. The NSMenu will retain the NSMenuView.
Hm, why is this method needed? Shouldn't this be done by the update method?
Method used by NSMenuItemCell to draw itself correctly and nicely lined up with the other menu items.
This is method is responsible for handling all events while the user is interacting with this menu. It should pass on this call to another menurepresentation when the user moves the mouse cursor over either a submenu or over the supermenu.
The method returns when the interaction from the user with the menu system is over.
The method returns NO
when the user
releases the mouse button above a submenu item
and YES
in all other cases.
This return value can be used to determine if submenus should be removed from the screen or that they are supposed to stay.
The implementation should roughly follow the following logic:
{ while (have not released mouse button) { if (mouse hovers over submenu, or supermenu) { if ([(menurepresentation under mouse) trackWithEvent: the event]) { [self detachSubmenu]; return YES; } return NO; } //highlight item under mouse if (highlighting submenu item) { [self attachSubmenuAtIndex:..]; } else { [self detachSubmenu]; } get next event. } execute the menu action if applicable; return YES | NO depending on the situation; }Note that actual implementations tend to be more complicated because because of all kind of useability issues. Useabilities issues to look out for are:
This will relayout the NSMenuView. It should be called when the menu changes. Changes include becoming detached, adding or removing submenu items etcetera. However, normally it does not need to be called directly because Because the NSMenuView is supposed to listen to the NSMenu notifications for the item added, removed and change notifications. It should be called explicitly when other changes occur, such as becoming detached or changing the title.