Developer Documentation
Table of Contents

_NSObsoleteMenuItemProtocol


Package:
com.apple.yellow.application

Interface Description


WARNING

The NSMenuItem protocol is being removed from the Application Kit. The NSMenuItem class will solely assume all associated functionality. This change does not affect binary compatibility between different versions of projects, but might cause failures in project builds. To adapt your projects to this change, alter all references to the protocol to references to the class .

Refer to the NSMenuItem class description, which replaces this.



Method Types


Enabling a menu item
setEnabled
isEnabled
Setting the target and action
setTarget
target
setAction
action
Setting the title
setTitle
title
Setting the tag
setTag
tag
Setting the state
setState
state
Setting the image
setImage
image
setOnStateImage
onStateImage
setOffStateImage
offStateImage
setMixedStateImage
mixedStateImage
Managing submenus
setSubmenu
submenu
hasSubmenu
Getting a separator item
isSeparatorItem
Setting the owning menu
setMenu
menu
Managing key equivalents
setKeyEquivalent
keyEquivalent
setKeyEquivalentModifierMask
keyEquivalentModifierMask
Managing mnemonics
setMnemonicLocation
mnemonicLocation
setTitleWithMnemonic
mnemonic
Managing user key equivalents
userKeyEquivalent
Representing an object
setRepresentedObject
representedObject


Instance Methods



action

public abstract NSSelector action()

Returns the receiver's action method.

See Also: target, setAction



hasSubmenu

public abstract boolean hasSubmenu()

Returns true if the receiver has a submenu, false if it doesn't.

See Also: - setSubmenuForItemsetSubmenu:forItem: (NSMenu)



image

public abstract NSImage image()

Returns the image displayed by the receiver, or null if it displays no image.

See Also: setImage



isEnabled

public abstract boolean isEnabled()

Returns true if the receiver is enabled, false if not.

See Also: setEnabled



isSeparatorItem

public abstract boolean isSeparatorItem()

Returns whether the receiver is a separator item (that is, a menu item used to visually segregate related menu items).

keyEquivalent

public abstract String keyEquivalent()

Returns the receiver's unmodified keyboard equivalent, or the empty string if one hasn't been defined. Use keyEquivalentModifierMask to determine the modifier mask for the key equivalent.

See Also: userKeyEquivalent, mnemonic, setKeyEquivalent



keyEquivalentModifierMask

public abstract int keyEquivalentModifierMask()

Returns the receiver's keyboard equivalent modifier mask.

See Also: setKeyEquivalentModifierMask



menu

public abstract NSMenu menu()

Returns the menu to which the receiver belongs, or null if no menu has been set.

See Also: setMenu



mixedStateImage

public abstract NSImage mixedStateImage()

Returns the image used to depict a "mixed state." A mixed state is useful for indicating "off" and "on" attribute values in a group of selected objects, such as a selection of text containing bold and plain (non-bolded) worlds.

See Also: setMixedStateImage



mnemonic

public abstract String mnemonic()

Returns the character in the menu item title that appears underlined for use as a mnemonic. If there is no mnemonic character, returns an empty string.

See Also: setTitleWithMnemonic



mnemonicLocation

public abstract int mnemonicLocation()

Returns the position of the underlined character in the menu item title used as a mnemonic. The position is the zero based index of that character in the title string. If the receiver has no mnemonic character, returns NotFound.

See Also: setMnemonicLocation



offStateImage

public abstract NSImage offStateImage()

Returns the image used to depict the receiver's "off" state, or null if the image has not been set. By default, there is no off state image.

See Also: setOffStateImage



onStateImage

public abstract NSImage onStateImage()

Returns the image used to depict the receiver's "on" state, or null if the image has not been set. By default, the on state image is a checkmark.

See Also: setOnStateImage



representedObject

public abstract Object representedObject()

Returns the object that the receiving menu item represents. For example, you might have a menu list the names of views that are swapped into the same panel. The represented objects would be the appropriate NSView objects. The user would then be able to switch back and forth between the different views that are displayed by selecting the various menu items.

See Also: tag, setRepresentedObject



setAction

public abstract void setAction(NSSelector aSelector)

Sets the receiver's action method to aSelector.

See Also: setTarget, action



setEnabled

public abstract void setEnabled(boolean flag)

Sets whether the receiver is enabled based on flag. If a menu item is disabled, its keyboard equivalent and mnemonic are also disabled. See the NSMenuValidation informal protocol specification for cautions regarding this method.

See Also: isEnabled



setImage

public abstract void setImage(NSImage menuImage)

Sets the receiver's image to menuImage. If menuImage is null, the current image (if any) is removed. This image is not affected by changes in menu-item state.

See Also: image



setKeyEquivalent

public abstract void setKeyEquivalent(String aKeyEquivalent)

Sets the receiver's unmodified key equivalent to aKeyEquivalent. If you want to remove the key equivalent from a menu item, pass an empty string ("") for aKeyEquivalent (never pass null). Use setKeyEquivalentModifierMask to set the appropriate mask for the modifier keys for the key equivalent.

See Also: setMnemonicLocation, keyEquivalent



setKeyEquivalentModifierMask

public abstract void setKeyEquivalentModifierMask(int mask)

Sets the receiver's keyboard equivalent modifiers (indicating modifiers such as the Shift or Alternate keys) to those in mask. mask is an integer bit field containing any of these modifier key masks, combined using the C bitwise OR operator:

You should always set CommandKeyMask in mask.

ShiftKeyMask is relevant only for function keys; that is, for key events whose modifier flags include FunctionKeyMask. For all other key events ShiftKeyMask is ignored and characters typed while the Shift key is pressed are interpreted as the shifted versions of those characters; for example, Command-Shift-'c' is interpreted as Command-'C'.

See the NSEvent class specification for more information about modifier mask values.

See Also: keyEquivalentModifierMask



setMenu

public abstract void setMenu(NSMenu aMenu)

Sets the receiver's menu to aMenu. This method is invoked by the owning NSMenu when the receiver is added or removed. You shouldn't have to invoke this method in your own code, although it can be overridden to provide specialized behavior.

See Also: menu



setMixedStateImage

public abstract void setMixedStateImage(NSImage itemImage)

Sets the image of the receiver that indicates a "mixed" state, that is, a state neither "on" or "off." If itemImage is null, any current mixed-state image is removed.

See Also: mixedStateImage, setOffStateImage, setOnStateImage, setState



setMnemonicLocation

public abstract void setMnemonicLocation(int location)

Sets the character of the menu item title at location that is to be underlined. location must be between 0 and 254. This character identifies the access key by which users can access the menu item.

See Also: mnemonicLocation



setOffStateImage

public abstract void setOffStateImage(NSImage itemImage)

Sets the image of the receiver that indicates an "off" state. If itemImage is null, any current off-state image is removed.

See Also: offStateImage, setMixedStateImage, setOffStateImage, setState



setOnStateImage

public abstract void setOnStateImage(NSImage itemImage)

Sets the image of the receiver that indicates an "on" state. If itemImage is null, any current on-state image is removed.

See Also: onStateImage, setMixedStateImage, setOffStateImage, setState



setRepresentedObject

public abstract void setRepresentedObject(Object anObject)

Sets the object represented by the receiver to anObject. By setting a represented object for a menu item you make an association between the menu item and that object. The represented object functions as a more specific form of tag that allows you to associate any object, not just an int, with the items in a menu.

For example, an NSView object might be associated with a menu item-when the user chooses the menu item, the represented object is fetched and displayed in a panel. Several menu items might control the display of multiple views in the same panel.

See Also: setTag, representedObject



setState

public abstract void setState(int itemState)

Sets the state of the receiver to itemState, which should be one of OffState, OnState, or MixedState. The image associated with the new state is displayed to the left of the menu item.

See Also: state, setMixedStateImage, setOffStateImage, setOnStateImage



setSubmenu

public abstract void setSubmenu(NSMenu aSubmenu)

Sets the submenu of the receiver to aSubmenu. The default implementation throws an exception if aSubmenu already has a supermenu.

See Also: submenu, hasSubmenu



setTag

public abstract void setTag(int anInt)

Sets the receiver's tag to anInt.

See Also: setRepresentedObject, tag



setTarget

public abstract void setTarget(Object anObject)

Sets the receiver's target to anObject.

See Also: setAction, target



setTitle

public abstract void setTitle(String aString)

Sets the receiver's title to aString.

See Also: title



setTitleWithMnemonic

public abstract void setTitleWithMnemonic(String aString)

Sets the title of a menu item with a character underlined to denote an access key. Use an ampersand character to mark the character (the one following the ampersand) to be underlined. For example, the following message causes the 'c' in 'Receive' to be underlined:
[aMenuItem.setTitleWithMnemonic ("Re&ceive");]

See Also: mnemonic, setMnemonicLocation



state

public abstract int state()

Returns the state of the receiver, which is OffState (the default), OnState, or MixedState.

See Also: setState



submenu

public abstract NSMenu submenu()

Returns the submenu associated with the receiving menu item, or null if no submenu is associated with it. If the receiver responds true to hasSubmenu, the submenu is returned.

See Also: hasSubmenu, setSubmenu



tag

public abstract int tag()

Returns the receiver's tag.

See Also: representedObject, setTag



target

public abstract Object target()

Returns the receiver's target.

See Also: action, setTarget



title

public abstract String title()

Returns the receiver's title.

See Also: setTitle



userKeyEquivalent

public abstract String userKeyEquivalent()

Returns the user-assigned key equivalent for the receiver.

See Also: keyEquivalent



userKeyEquivalentModifierMask

public abstract int userKeyEquivalentModifierMask()

Description forthcoming.


Table of Contents