On Sep 12, 2006, at 4:07 AM, Steven Hedgepeth wrote:


If this list is monitored by RealSoftware, please read:

Regarding Menu Items (such as File-New),

In the code window under Menu Handlers I notice that FileNew is treated as a function in RB so I go to the LR to determine what I should return and I see:

result = Action( ) 'result is boolean

Not understanding why a Menu Handler has to be a function (this is my first project using RB and I'm assuming that Action refers to clicking on a menu item) I look at the only other information provided by the LR:

"Fires when a MenuItem is selected. Return True to prevent the menu event from proceeding any further in the chain of menu handlers."

The first sentence makes sense. The second sentence leaves me asking the following questions: 1. Why would the menu event (FileNew) continue into other menu handlers? After all, I didn't trigger those events (FileOpen, FileSave, FileQuit) I only triggered the FileNew event. Certainly, for my mental well-being if nothing else, RB couldn't possibly be designed so that if a user triggers one menu event, all the rest of the menu events are triggered as well unless the intended menu event returns true. Or does RB indeed behave this way and if so, why?

No, it doesn't behave that way. Selecting FileNew generates a 'FileNew' menu event, not a 'FileOpen' menu event or a 'FileSave' menu event. Rb sends a FileNew menu event to program elements, looking for FileNew menuhandlers. For example, if an editfield or listbox has the current focus then it gets a FileNew menu event. If you have placed a FileNew menuhandler there then it will be executed. Of course, you probably didn't place a FileNew eventhandler in a listbox subclass, but if it's there it gets executed. If you put Return True there, then that is the end of it, the FileNew event goes nowhere else. But if there is no Return True then the event continues 'down the chain' which likely includes the frontmost window, the Application subclass, and the menuitem subclass.

When the menuitem is selected, Rb doesn't know in advance where you have handled it, so it goes looking in a systematic manner, and it gives you the flexibility to handle the event in more than one program element or not, and to set controlling conditionals if you wish.

Best,

Jack



_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Reply via email to