Log In    |    Knowledge Base    |    4D Home
Tech Tip: The Pop up menu command
Published On: January 3, 2003

Compatibility: Version 6.7.x and 6.8.x

Introduced in version 6.0, the Pop up menu command provides developers with a an easy way to enhance an application's user interface.

Whenever your code executes the Pop up menu command, a popup menu is drawn on screen at the current location of the cursor. The command returns the number of the selected item in the popup menu.

When used with one or more modifier keys (Control, Alt or Option, or Command), you can provide your users with choices that are appropriate for the item they clicked on. This can help reduce clutter on your forms, and also provide choices that are appropriate for some users, and not for others.

For example, instead of having a button on a form for copying the contents of a field to the clipboard, you can use the following code in the field's object script:

Case of
:(Form event = On clicked)
 $selectedItem:=Pop up menu ("Copy to clipboard")
 Case of
  :($selectedItem = 1)
 End case
End case

Another useful application of this command is to allow the user to easily change items in an element of a scrollable area. Simply put your code that calls the Pop up menu command in the object script of the scrollable area. When the user clicks on a row in the scrollable area, a popup menu will appear, and by using the following code, you can update the contents of the selected list item:

$selectedItem := Pop up menu("Item1;Item2;Item3")

If($selectedItem#0) `if the user selected a valid item
 Case of
  Self->{Self->} := "Item1"
  Self->{Self->} := "Item2"
  Self->{Self->} := "Item3"
 End case
End if

Details about how to use the command can be found at: