4D v16.3

Building menus

Home

 
4D v16.3
Building menus

Building menus  


 

When you create a new database, 4D automatically creates a default menu bar (Menu Bar #1) including standard menus and a command for returning to the Design mode. 

This allows the user to access the Application environment as soon as the database is created. Menu Bar #1 is called automatically when the Test Application command is chosen in the Run menu. 

The default menu bar includes three menus: File, Edit and Mode.

  • File: This menu only includes the Quit command. The Quit standard action is associated with the command, which causes the application to quit.
  • Edit(standard): The Edit menu is standard and completely modifiable. Editing functions such as copy, paste, etc. are defined using standard actions.
  • Mode: The Mode menu contains, by default, the Return to Design mode command, which is used to exit the Application mode.

Note: Menu items appear in italics because they consist of references and not hard-coded text. For more information about this point, refer to Using references for menu titles

You can modify this menu bar as desired or create additional ones.

This section describes the process of creating a custom menu bar.

Note: It is possible to create menu bars entirely by programming. For more information about this point, refer to the Menus chapter in the 4D Language Reference manual. 

To create a menu bar:

  1. Display the “Menus” page of the 4D tool box.
    4D displays the Menu Bar editor. By default, Menu Bar #1 appears in the panel on the left — as well as any other menu bars that may already have been created.
    4D assigns menu bar numbers sequentially — Menu Bar #1 appears first. You can rename menu bars but you cannot change their numbers. These numbers are used by the language commands.
  2. Click the add button below the menu bar area.
    OR
    Choose Create a new menu bar from the context menu of the list or the options menu below the list.
    A new menu bar appears in the list containing the default menus (File and Edit).
  3. Alt+click (Windows) or Option+click (Mac OS) on the name of the menu bar or click twice on it in order to switch it to editing mode and enter a custom name (optional)
    OR
    Enter the custom name in the “Title” area.
    A custom name can facilitate the identification of menu bars in the different dialog boxes of the Design environment and in the language commands. A menu bar name may contain up to 31 characters and must be unique.
    At this point, you can begin modifying menu bars or adding menus, commands to the menus, etc.

You can create menus at any time. They can then be attached to menu bars or to other menus (hierarchical submenus), or they can not be attached to any menu bar (or menu) and be handled by programming only (independent menus). 

You don’t have to create the menus in the order that they will eventually appear. You can rearrange menus after you’ve created them using drag and drop (see the “Rearranging menus and menu commands” section).

Note: It is possible to create menus entirely by programming. For more information about this point, refer to the Menus  chapter in the Language Reference manual.

To create a menu:

  1. Display the “Menus” page of the 4D tool box.
  2. Select the “Menus” title or an existing menu in the list of source menus and click on the button.
    OR
    Choose Create a new menu in the context menu (click on the “Menus” title or on an existing menu) or in the options menu of the editor.
    4D adds a new menu to the bottom of the list.
  3. Alt+click (Windows) or Option+click (Mac OS) on the menu name or click on it in order to switch it to editing mode and enter a custom name.
    OR
    Enter the custom name in the “Title” area.
    You can enter the menu name as “hard coded” or enter a reference for a variable, a resource or an XLIFF element. For more information about this point, refer to Using references for menu titles.
    If you enter the name directly, you must avoid any control characters that may disturb the menu display (see the “Using control characters in menu labels” section).
  4. Repeat steps 2 and 3 to add more menus (optional).
    You can preview a menu that you are creating at any time by selecting the source menu then clicking in the preview area on the right-hand side of the editor.

For each of the menus, you must create the commands that appear when the menu drops down. You can insert items that will be associated with methods or standard actions, or attach other menus (submenus). Attaching hierarchical submenus is described in Attaching menus

To add a menu command:

  1. In the list of source menus, select the menu to which you want to add a command.
    If the menu already has commands, they will be displayed in the central list. If you want to insert the new command, select the command that you want it to appear above. It will still be possible to reorder the menu subsequently.
  2. Choose Add an item to the menu “MenuNamein the options menu of the editor or from the context menu (right click in the central list).
    OR
    Click on the add button located below the central list.
    4D adds a new item with the default name “Item X” where X is the number of items already created.
  3. Alt+click (Windows) or Option+click (Mac OS) or click twice on the name of the command in order to switch it to editing mode and enter a custom name.
    OR
    Enter the custom name in the “Title” area.
    You can enter the menu name as “hard coded” or enter a reference for a variable, a resource or an XLIFF element. For more information about this point, refer to  Using references for menu titles. If you enter the name directly, you must avoid any control characters that may disturb the menu display (see the following section).
  4. (Optional) Enter a custom reference in the “Parameter” area.
    This reference can be used by language commands. For more information about this point, refer to the Custom parameter section.
  5. Repeat steps 1 to 4 to add more commands.

You can set the properties of the menu commands by using control characters (metacharacters) directly in the menu command labels. For instance, you can assign the keyboard shortcut Ctrl+G (Windows) or Command+G (Mac OS) for a menu command by placing the “/G” characters in the label of the menu item label. 

Control characters do not appear in the menu command labels. You should therefore avoid using them so as not to have any undesirable effects. The control characters are the following:

  • ( (open parentheses)
  • < (less than)
  • ! (exclamation point)
  • ^ (circumflex accent)
  • / (slash)

For more information on the use of these characters, refer to the description of the APPEND MENU ITEM command in the 4D Language Reference manual.

After you create the menus for a menu bar and the menu commands for a menu, you can reorder them using drag and drop. To insert a menu command at a different place in the order, simply drag it to the new location. To move a menu, simply drag it to another location in the list of menus.

You can delete a menu bar, a menu or a menu item at any time. Note that each menu or menu bar has only one reference. When a menu is attached to different bars or different menus (see Attaching menus), any modification or deletion made to the menu is immediately carried out in all other occurrences of this menu. 

To delete a menu bar, menu or menu item, you have two possibilities:

  • Select the item to be deleted and click on the deletion button located beneath the list.
  • Use the Delete the menu bar “”, Delete the menu “” or Delete the item “” commands from the context menu or the options menu of the editor.

Note: It is not possible to delete Menu Bar #1.

 
PROPERTIES 

Product: 4D
Theme: Menus and menu bars

 
HISTORY 

 
ARTICLE USAGE

4D Design Reference ( 4D v16)
4D Design Reference ( 4D v16.1)
4D Design Reference ( 4D v16.3)