Class: cWebMenuItem

Properties  Events  Methods    Index of Classes

The Web Framework menu item/toolbar item

Hierarchy

cObject
---cWebObject
------cWebBaseUIObject
---------cWebMenuItem
------------cWebMenuClear
------------cWebMenuClearAll
------------cWebMenuDelete
------------cWebMenuFind
------------cWebMenuFindFirst
------------cWebMenuFindLast
------------cWebMenuFindNext
------------cWebMenuFindPrevious
------------cWebMenuItemCheckbox
------------cWebMenuItemLoadView
------------cWebMenuPrompt
------------cWebMenuSave

Library: Web Application Class Library

Package: cWebMenuItem.pkg

Description

The cWebMenuItem class is used to construct the items that make up a menu bar or a tool bar.



Menu items are the objects that perform some action in your web application. For example: saving a record, opening a view, changing the user login, or any action that the user may need to initiate in your web application.

When used inside a menu bar (cWebMenuBar), the menu items form the top visible layer of selectable menus in the menu bar. The list of items for each menu is formed by creating nested menu item objects. This nesting can continue to any desired level, thus creating layers of nested sub-menus.

When used inside a toolbar (cWebToolBar), the menu items form the toolbar buttons.

Sample

Object oFileMenu is a cWebMenuItem
    Set psCaption to "File"
                
    Object oClearMenuItem is a cWebMenuClear
    End_Object  
                
    Object oSaveMenuItem is a cWebMenuSave
    End_Object  
                
    Object oDeleteMenuItem is a cWebMenuDelete
    End_Object  
                
    Object oLoginMenuItem is a cWebMenuItem
        Set psCaption to "Log In"
        Set pbBeginGroup to True

        Procedure OnClick
            Send RequestLogin to ghoWebSessionManager
        End_Procedure
    End_Object
End_Object

The above sample demonstrates a 'File' pull-down menu with items for 'Clear', 'Save', 'Delete' and 'Login'.

Note that the Clear, Save and Delete items use special subclasses of cWebMenuItem, for example cWebMenuSave. These subclasses are pre-fabricated to perform a single task (in this case request the focused view to save a record).

Object Name

The Web Framework uniquely identifies each web object via a combination of the object hierarchy (object nesting), and object name. This means that web object names must be unique within their parent (i.e. each sibling web object must have a unique name).

Object Placement

Menu item objects must be placed inside a menu bar (cWebMenuBar), a toolbar (cWebToolBar) or another menu item object.

Appearance

Set pbBeginGroup to True to draw a group line above (before) the menu item.

Set psCaption to specify the text that is displayed in the menu item.

Set psImage to the image you wish to display in the menu item. The image must be reachable from the web application's URL.

Set psToolTip to specify the tooltip text to be displayed as the mouse is hovered over the item.

The colors and fonts used by a menu item are determined by the web application's CSS theme (psTheme). You can define additional or replacement CSS styles in your web application's application.css file. Set psCSSClass to the CSS class name you would like to be applied to a list control.

Menu Actions

When a menu item is selected (or clicked) it will generate an OnClick event. Click events can be handled on the server by writing DataFlex code. A click can also be handled on the client (browser) by writing JavaScript code. Writing a server-side DataFlex handler is the simplest way to handle menu item click events.

Write an OnClick event handler in your menu item object to perform some action when the menu item is selected.

Set pbServerOnClick to False to prevent the OnClick event from being sent to the server. By default, this property is True.

To write a client-side menu item OnClick handler using JavaScript, set the psClientOnClick property to the name of the JavaScript function that will execute when the button is clicked.

See cWebMenuItemLoadView regarding activating views from menus.

Enabling/Disabling Menu Items

Set pbEnabled to False to disable a menu item. The menu item text is displayed in the disabled color.

If your menu item sets psLoadViewOnClick then the menu item will automatically set pbEnabled to False if the currently logged in user does not have access rights to the view. For more information, see AllowAccess.

Set pbRender to False to remove the menu control from the client HTML. The menu object still exists but it is completely removed from the menu or toolbar. The space previously occupied by the menu item is removed and occupied by the next menu item (if present).

Menu Item Subclasses

A number of menu item sub-classes have been created that are designed to handle most of the commonly needed menu actions such as finding and saving. These easily can be added to any menu or toolbar and used without adding any extra code. These classes are listed above in the sub-class hierarchy list and the first sample shown at the top of this section shows how these classes are used.

Drag and Drop Support

This control can be used as a valid drop target by registering it as such in a cWebDragDropHelper object.

The supported actions for this control are:
- C_WebDropOnControl

This allows the control to accept data dragged from elsewhere in the control (if configured that way) and can also be used to accept files when registered within a cWebDragDropFileHelper.

See Also

Styling Web Applications