O'Reilly logo

REALBasic: TDG, 2nd Edition by Matt Neuburg

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Menu Item Functionality

This section describes how your application actually does anything when the user chooses a menu item. Apart from some of the default menu items described earlier (in Section 6.3), choosing a menu item has no effect whatever unless your code responds. Here’s how to make it respond.

Menu Events

When a menu item is chosen, by way of the mouse or a Command key equivalent, REALbasic sends a menu event. It is up to your code to handle this menu event, in a menu event handler . In a MenuItem subclass, the menu event handler is provided for you, but otherwise creating a menu event handler is up to you. You must decide where to put it, and to do so, you need to understand where menu events are sent. The sequence resembles, but is not identical to, the sequence of events during a menu-enabling moment:

  1. If an instance of an EditField or ListBox subclass has the focus, the instance receives a menu event.

  2. The frontmost visible nonfloating window receives the same menu event.

  3. The Application subclass receives the same menu event. This does not happen, though, if the frontmost visible window is modal.

  4. If the chosen menu item is an instance of a MenuItem subclass, then it receives the same menu event. This does not happen, though, if the frontmost visible window is modal.

On Windows, a modal window behaves like a floating window for purposes of these rules; in other words, a modal window itself does not block or receive any menu events.

During the first three stages, the ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required