Class: MenuBar [Obsolete]

Properties  Events  Methods    Index of Classes

Provides the capabilities of a standard GUI menu bar

Hierarchy

cObject
---cUIObject
------DfBaseObject
---------DfBaseWindow
------------DfBaseUIWindow
---------------DfBaseControl
------------------DfBaseList
---------------------DfBaseActionBar
------------------------MenuBar

Library: Windows Application Class Library

Package: Windows.pkg

Mixins: StatusHelp_Item_Mixin

Description

This class is obsolete. Menus are now created using class cCJMenuBar.

As of revision 12.1, DataFlex includes full support for Codejock Software's COM Xtreme CommandBars package for creating menus, toolbars and statusbars. See Using Menus, Toolbars and Statusbars for more information.




The MenuBar class provides the capabilities of a standard GUI menu bar.

Sample

Register_object FileMenu
Register_object ToolMenu
 
Object MainPanel is a Panel
    :
    Object ActionBar is a MenuBar
        Item_List
            On_Item "&File"  send MenuPopup to (FileMenu(self))
            Set Status_Help to "Display file menu options."
            On_Item "&Tools" send MenuPopup to (ToolMenu(self))
            Set Status_Help to "Display tools menu options."
            On_Item "T&asks" send Task_popup
            Set Status_Help to "Popup local task tool menu."
        End_Item_List
 
        Object FileMenu is a PopupMenu
            :
        End_Object
 
        Object ToolMenu is a PopupMenu
            :
        End_Object
 
        Procedure Task_Popup
            integer Foc
            get focus to foc
            Send Start_task to foc
        End_Procedure
 
    End_Object
    :
End_Object


Syntax

Use windows
:
Object object_name is a MenuBar
    Item_List
        On_Item MenuText Send message [to dest_object]
        Set Status_Help to StatusHelpText
        :
    End_Item_List
End_Object


Of Special Note

The MenuBar class is a subclass of the DfBaseList class and inherits its item-based interface. Items in a MenuBar are normally created using the item_list / end_item_list syntax. Items may also be created, changed and deleted using the dynamic item-interface messages (delete_data, Add_item, Insert_item, delete_item). Items should only be added or deleted when the menu bar is inactive.

Each item in a MenuBar is defined with the following properties: Value, Message, Aux_Value, Shadow_state, and status_help.

Value An item's value is the text that will be displayed in a menu item. It is set by the on_item command, the add_item and insert_item messages, and can be directly changed with the set value message.
Message and Aux_Value An item's message determines the message that will be sent when the item is selected. If aux_value is 0, the message is sent to the current focus object. If aux_value is non-zero, the message is sent to the object ID in aux_value. If the message is MenuPopup (or 0), the object ID represented in Aux_Value is activated as a popup menu. This is the method used by menubar objects to create PopupMenu "pulldown" objects.
Shadow_State If an item's shadow_state is true, the item will appear disabled and users will be unable to select the item.
Status_Help Each item may have status-help text associated with it. When the menu item is selected, this help will appear in the status bar.


The Focus

The menu bar and its popup-menu children never take the focus. When a MenuBar or PopupMenu is selected, the focus does not change and no focus-change messages are sent. This is actually a very useful feature. If you wish to know what object was the focus object when the menu bar was selected, simply get the focus property.

Character Highlighting

A highlight character may be defined by prefixing the & symbol to the letter that should be highlighted. When the Alt key plus the highlighted letter is pressed, the highlighted letter's popup menu will be activated.

On_Item "&File" Send PopupMenu to (obj(self))



MenuBar Events

Each time a menubar object (or one of its PopupMenu objects) is selected, the event message onInitMenu is sent. This is a notification that the menu is now active. The message InitializeMenu is also sent. If you augment this message, you must remember to forward it. When a PopupMenu is being exited, the message Exit_Menu is sent. If augmented, this also must be forwarded.

Any time any menu item change occurs within the MenuBar or within any PopupMenu in the MenuBar, the message change_menu is sent to the MenuBar. This message is passed both an item number and an object number. This allows the message to determine which object caused the event. If augmented, this must be forwarded-it controls the display of status help.

MenuBar system

The menu-bar-system package defined in DfMenu.pkg provides a number of macro commands to make it easier to create MenuBar / PopupMenu systems. This is described in the Menu System section.