KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Customize contextual menu for enterable text objects
PRODUCT: 4D | VERSION: 14.3 | PLATFORM: Mac & Win
Published On: June 17, 2015

Enterable text objects can enable contextual menus. The default menu options are cut, copy, and paste. Below is an example on how to customize the contextual menu that appears.

In the on click form event of the text object use GET MOUSE to determine the mouse button pressed. If the right mouse button is pressed, use POP UP MENU to bring up your own custom menu. The code below demonstrates these steps:

Case of
   : (Form event=On Clicked)
     FILTER EVENT //to prevent default contextual menu from coming up
     GET MOUSE(mX;mY;mB)
     Case of
        : (mB=2) //right button down
          $choice:=Pop up menu("Item1;Item2;Item3";1;mX;mY)
      end case
end case


The resulting menu will come up: