Why don't my popup menus work?

Tuesday, July 22 2003 @ 05:26 PM UTC

Contributed by: witness

Have a popup menu control that shows its popup, but when you select a menu item, the control doesn't notice the change?

If your popup menu controls suddenly don't change their selection (and value) in response to a menu selection, there are two reasons why this may be so:

1) You added the menu items dynamically, and forgot to call SetControlMaximum(CountMItems(theMenu)) and hence, SetControlValue() restricts the value to zero, or the number of items originally in the menu.

2) You have a Carbon event handler that handles kEventProcessCommand Carbon Events and always returns noErr. Carbon event handlers installed on the application or the window are also called when menus in popup menu controls are selected, and when a Carbon event handler returns noErr, it means "everything OK, I've taken care of this event, no need to have anyone else handle it".

But for menu items that your handler doesn't really handle, it should instead return eventNotHandledErr, to give someone higher up in the calling chain the opportunity to handle the menu selection, like a popup menu control.