Instance Method

insertItemWithTitle:action:keyEquivalent:atIndex:

Creates and adds a menu item at a specified location in the menu.

Declaration

- (NSMenuItem *)insertItemWithTitle:(NSString *)string action:(SEL)selector keyEquivalent:(NSString *)charCode atIndex:(NSInteger)index;

Parameters

aString

A string to be made the title of the menu item.

aSelector

The action-message selector to assign to the menu item.

keyEquiv

A string identifying the key to use as a key equivalent for the menu item. If you do not want the menu item to have a key equivalent, keyEquiv should be an empty string (@"") and not nil.

index

An integer index identifying the location of the menu item in the menu.

Return Value

The new menu item (an object conforming to the NSMenuItem protocol) or nil if the item could not be created

See Also

Adding and Removing Menu Items

- insertItem:atIndex:

Inserts a menu item into the menu at a specific location.

- addItem:

Adds a menu item to the end of the menu.

- addItemWithTitle:action:keyEquivalent:

Creates a new menu item and adds it to the end of the menu.

- removeItem:

Removes a menu item from the menu.

- removeItemAtIndex:

Removes the menu item at a specified location in the menu.

- itemChanged:

Invoked when a menu item is modified visually (for example, its title changes).

- removeAllItems

Removes all the menu items in the menu.