Each GENEXUS object defined for graphic environments that make use of Forms can have its own Menu Bar and Tool Bar. GENEXUS object to implement this: MenuBar.
Attention: This object is only available for the graphic generators (Visual Basic, Java and Visual FoxPro).
Menu Bars are defined via the Object/New Object menu option (or clicking over the create object icon) and they consist of:
Name and description.
Items and sub-items. Items are main menu bar options placed on the top of the menu bar for example: File, Edit, etc. Sub-items are the inner options of the main items, for example: Exit is accessed after you select File from main menu bar. Each item/sub-item has a:
Name. Is the identifier we will make reference to when used in events. There are some options that have special meanings for <small>GENEXUS</small>, for example, Exit. Each of the names corresponding to special items start with GX, note that events cannot be defined for them.
Caption. Is the name displayed on the Form. If & is used within the caption name then the following letter will be used as a Short Cut Key. For example: Tit&le will appear on the Form as Title, this means that Alt-l will directly access the option.
Separator. The item is simply a separator.
Sub-items. Events can not be associated to them.
Checked. The item will be displayed as checked.
Enabled. Enables item selection.
Shortcut Key. This tag lets you define a key combination that offers a quick access to a desired option. Remember to add an ‘&’ before the letter used for quick access when inserting the caption so that the user can view the shortcut key (see caption). Important: Items, contrary to sub-items, can not be assign shortcut keys.
Note: be careful not to assign the same shortcut key to more than one sub-item because GENEXUS doesn’t control that.
You can add or delete Menu bar items via the respective Edit/Insert and Edit/Delete main menu options. You can also move items (drag & drop with mouse) or copy them (drag & drop with mouse holding down the Ctrl key).
A floating properties window will appear when double-clicking over an item you wish to edit or you start to write something over a selected option, this window may be left opened by clicking the button on the upper right corner.
Items can be either for the Menu bar or the associated Tool Bar. The definition is the same for both; the only difference is that the tool bar items have an associated bitmap:
Each item without subitems can be associated to an event. Events are selected choosing the Insert/Events (CTRL+E) menu option. These are general events and they will be executed in all objects that use the Menu Bar, this is the reason why attributes may not be used.
call(WWrkCli) // calls work panel "Work with Clients"
Once the Menu Bar is defined, you must indicate in which of the objects it will be used. In order to do this a new property was defined for transactions and work panels under the Windows Interface group: Menu bar (a combo displays all existing menu bars). If a Menu Bar has not been associated to an object then a default Menu Bar will be used.
You can also program events for menu bar items in these objects (transactions and work panels). E.g.:
As the object in which they have been defined only uses these events, then attributes can be used.
If the same event has been programmed in the menu bar and in the object, the one that is actually executed will be the one that was defined directly within the object. Thus, you can program the generic behavior of a Menu Bar and something more particular for an object.
Menu bars must be generated (independently from the objects that use it). If a Menu Bar changes there is no need to regenerate the objects that use it.
In the events (Insert/Event, shortcut Ctrl+E) of objects that have an associated menubar it is possible to paste the events defined in the menubar. The event names that can be selected are the ones defined in option Name of the menubar or toolbar. The menubar considered to select the available events is the one set in the object's properties, that is, if the menubar set in the properties is changed then the events available to select will also be changed. Once the menubar is set in the object's properties, the available events are the ones saved to that moment. If the menubar is being edited, the events will not be available to paste until they are saved.
- The item Help/About calls a work panel named GXABOUT. This work panel is provided by <small>GENEXUS</small> by default, in case you wish to customize it you must create a new work panel with this name (gxabout) with the desired information.
The menu bar of a Main object is not "inherited" by the other objects of the executable file (that is, other non-main object in the same executable file) nor by other main objects called by it.
The size of the bitmaps used in the toolbar must be (in pixels): width=16 and height=15