Skip to content

Class: FormFloatingPopupMenu

Properties | Events | Methods | Index of Classes

Creates standard floating popup menus for Windows forms (context menus)

Hierarchy

cObject > cUIObject > DfBaseObject > DfBaseWindow > DfBaseUIWindow > DfBaseControl > DfBaseList > DfBaseActionBar > DfBasePullDown > DfBaseEditPullDown > FormFloatingPopupMenu

Show full hierarchy and direct subclasses

Library: Windows Application Class Library

Package: Windows.pkg

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.

FormFloatingPopupMenu is used to create standard floating popup menus. This is used to create a "right-mouse-button context menu". This creates a menu of items for standard form-edit operations (undo, cut, copy, paste, delete and select all). An object is automatically created based on this class and all non-DEO form controls use this object.

The FloatingPopupMenu class contains no default items and all items must be provided by the developer.

Sample

Object oCustomMenu is a FormFloatingPopupMenu
    // these get added to the existing items.
    Send Add_Item msg_none "" // create a spacer
    Send Add_Item msg_Exit_Application  "E&xit Application"

    Procedure Popup
        integer iFocus iItemCount
        boolean bChanged

        Get Focus to iFocus // the object that called us
        Get Changed_State of iFocus to bChanged
        Get Item_Count to iItemCount // exit is the last item
        // if changed, shadow exit option
        Set Shadow_State (iItemCount - 1) to bChanged

        forward send Popup
    End_Procedure  // Popup
End_Object

Syntax

Use windows.pkg
:
Object object_name is a FormFloatingPopupMenu
    Send Add_Item message MenuText 
    Set Aux_Value item (item_count(self)-1) to ObjectId // optional destination
    :
    Send Add_Item msg_none ""    // separator
    :
    Procedure Popup
        :
        Set Shadow_State item item# to true|false
        :
        Forward send popup
    End_Procedure
End_Object

    In your Form object:

Set Floating_Menu_Object to object_name

Of Special Note

Automatic Floating Popup Menu Support By default an object named FormFloatingMenu is created based on this class. Non DEO Form objects (form, grid, etc.) use this object for floating context menu support. When the right mouse button is pressed in a form, the form object is given the focus, and, if this focus change is successful the popup message is sent to the FormFloatingMenu object. This causes the context menu to appear relative to the location of the mouse pointer. This provides support for the standard editing operations (undo, cut, copy, paste, delete, and select all).

DEO forms (dbForm, dbGrid, etc.) use a more-sophisticated popup menu which supports all the standard editing support plus many data entry options (save, prompt, clear, delete, find, etc.). (See dbFloatingPopupMenu for more information on this.)

All of this is provided automatically. No program changes are required to support this. In addition to this automatic support an interface is provided to customize these behaviors.

Assigning a Floating Menu to a Form

When a program is run an object named FormFloatingMenu is created based on this class. In addition a global integer, default_form_floating_menu_id, is created which contains the object id of FormFloatingMenu.

Form objects (form, grid, dbForm, dbGrid, etc.) have a property named floating_menu_object. This contains the object ID of the floating popup menu object that should be used when the right mouse button is selected. When a non DEO form object (form, grid) is created the floating_menu_object property is set to the value of the default_form_floating_menu_id. This is the method used to assign an object to a floating context menu. If you wish to assign a different floating menu to a form you may either set the form's floating_menu_object property or you may change the value of global integer default_form_floating_menu_Id. You would do the later if you wished to change the assignment of floating menus within all forms.

Customizing a Floating Popup Menu

Floating menus support a standard item interface. Items are changed by sending the messages Add_Item, Insert_Item, Delete_item, and Delete_Data. Item characteristics are changed by setting the properties value, aux_value, message and shadow_state. This interface is identical to the PopupMenu interface. These items may be set when the object is created, or, when the object is about to be invoked. You should augment the Popup message to dynamically change menu item values.

Some examples should clarify this. The following example creates an object that adds the option "Exit application" to the menu. In addition, this item will shadowed if the invoking form's changed_state is true.

Object CustomMenu is a FloatingPopupMenu
    // these get added to the existing items.
    Send Add_Item msg_none "" // create a spacer
    Send Add_Item msg_exit_application  "E&xit Application"    

    Procedure Popup
        integer foc changed Itm
        Get focus to foc // the object that called us
        Get Changed_State of foc to changed
        Get Item_Count to Itm // exit is the last item
        // if changed, shadow exit option
        Set Shadow_state item (itm-1) to changed         
End_Object

This could be assigned to a form by setting the form's property as follows:

Object MyForm is a Form
    :
    Set Form_Menu_Object to (CustomMenu(self))
End_Object

Or, all form objects could be assigned to this custom menu with the following:

Move (CustomMenu(self)) to default_form_floating_menu_id

All forms created after this statement will be assigned to new context menu.

Subclasses of the FormFloatingPopupMenu

The dbFormFloatingPopupMenu creates a DEO floating popup menu and is used automatically by DEO forms (dbForm, dbGrid, etc.). The FloatingPopupMenu creates a floating menu with no items.

No new properties are created for this class. It is expected that you will use the following item properties: value, aux_value, message, and shadow_state.

No new procedures or functions are created for this class. It is expected that you will use the following messages: send add_Item, send insert_value, send delete_item, send delete_data, get item_count, and, send popup. Note that you will not use the following messages from the PopupMenu class: onInitMenu (use Popup instead), change_menu and redirect_message.