Create your own contextual menu for 4D Write Pro

4D gives you new possibilities to customize your 4D Write Pro user interface to make it perfectly fit your business application. Instead of using the default 4D Write Pro contextual menu, which is so detailed that it could become unpleasant to use, the 4D developer can create its own contextual menu, with the exact list of actions that he wants to provide.

Since 4D v16 R3, you can:

  • Replace the default contextual menu with your own menu,
  • Choose the actions you want to display,
  • Rearrange the item order at your convenience,
  • Create your own hierarchy by adding sub-menus.

You think that reproduce this menu is cumbersome and complicated? Not at all, using standard actions, it is very easy!

Download our example

If you want how to create your own contextual menu, please download our example database:

Example Database

Example highlights

Below are listed the key points of the attached example database so that you know the different programming steps to build your own 4D Write Pro contextual menu:

Associate your contextual menu to 4D Write Pro area

4D methodIn the 4D Write Pro object method, you associate your menu to the contextual menu of object with the Dynamic pop up menu command. In below, you have a code example:

Case of
    : (Form event=On Clicked)
        If (Contextual click)
            Dynamic pop up menu(myMenu)
        End if
End case

 

Create your menu

4D methodIn the Form method, you can create your own menu, on the “On Load” event for example. In below, you have a code example:

Case of
    : (Form event=On Load)
        C_TEXT(myMenu)
        createMyMenu
    : (Form event=On Unload)
        // release menu
        RELEASE MENU(myMenu)
End case

Don’t forget to release the menu when you have finish to use it; For example on the “On Unload” event.

4D methodThe createMyMenu method ……

// Create menu
myMenu:=Create menu

Add menu item

// Insert the "copy" item
APPEND MENU ITEM(myMenu;ak standard action title)
SET MENU ITEM PROPERTY(myMenu;-1;Associated standard action;ak copy)

Add an automatic sub-menu

// Insert the "fontStyle" myMenu
APPEND MENU ITEM(myMenu;ak standard action title)
SET MENU ITEM PROPERTY(myMenu;-1;Associated standard action;ak font style)

Add an customized sub-menu

// Create sub menu size
menuSubSize:=Create menu
// Insert a sub menu item
APPEND MENU ITEM(menuSubSize;ak standard action title)
SET MENU ITEM PROPERTY(menuSubSize;-1;Associated standard action;"fontSize?value=10pt")
// Associate the "menuSubSize" sub-menu to the "Size" item of myMenu
APPEND MENU ITEM(myMenu;"Size";menuSubSize)

 

Vanessa Talbot
• Product Owner •Vanessa Talbot joined 4D Program team in June, 2014. As a Product Owner, she is in charge of writing the user stories then translating it to functional specifications. Her role is also to make sure that the feature implementation delivered is meeting the customer need.Since her arrival, she has worked to define key features in 4D. She has worked on most of preemptive multi-threading new features and also on a very complex subject: the new architecture for engined application. Vanessa has a degree from Telecom Saint-Etienne. She began her career at the Criminal Research Institute as a developer for the audiovisual department. She has also worked in media and medical fields as expert in technical support, production as well as documenting new features.