Instance Method

numberOfItemsInMenu:

Invoked when a menu is about to be displayed at the start of a tracking session so the delegate can specify the number of items in the menu.

Declaration

- (NSInteger)numberOfItemsInMenu:(NSMenu *)menu;

Parameters

menu

The menu object about to be displayed.

Return Value

The number of menu items in the menu.

Discussion

If you return a positive value, the menu is resized by either removing or adding items. Newly created items are blank. After the menu is resized, your menu:updateItem:atIndex:shouldCancel: method is called for each item. If you return a negative value, the number of items is left unchanged and menu:updateItem:atIndex:shouldCancel: is not called. If you can populate the menu quickly, you can implement menuNeedsUpdate: instead of numberOfItemsInMenu: and menu:updateItem:atIndex:shouldCancel:.

See Also

Handling Tracking

- menuNeedsUpdate:

Invoked when a menu is about to be displayed at the start of a tracking session.