Components | All | New | MacOS | Windows | Linux | iOS | ||||
Examples | Mac & Win | Server | Client | Guides | Statistic | FMM | Blog | Deprecated | Old |
Menu.AddItem
Adds a menu item to the end of the menu.
Component | Version | macOS | Windows | Linux | Server | iOS SDK |
Menu | 4.1 | ✅ Yes | ✅ Yes | ❌ No | ❌ No | ❌ No |
Parameters
Parameter | Description | Example |
---|---|---|
menu | The reference to the menu. Please create one with Menu.CreateMenu. | $menu |
item | The reference to the menu item. Please create one with MenuItem.CreateMenuItem or MenuItem.CreateSeparator. | $item |
Result
Returns OK or error.
Description
Adds a menu item to the end of the menu.Thus, the receiver does not accept the menu item if it already belongs to another menu. After adding the menu item, the receiver updates itself.
Examples
Show a context menu based on a table with menu entries:
# go to layout with menu entries
Go to Layout [ “REP” (REP Reports) ]
# this script can be called with various groups
Set Variable [ $type ; Value: Get(ScriptParameter) ]
# make a new menu
Set Variable [ $menu ; Value: MBS( "Menu.CreateMenu") ]
# loop over records
Go to Record/Request/Page [ First ]
Loop
# if group matches
If [ REP Reports::Group = $type ]
# add new menu item with title from table
Set Variable [ $item ; Value: MBS( "MenuItem.CreateMenuItem"; REP Reports::LabelReport) ]
# define which script to call if menu item is selected
Set Variable [ $r ; Value: MBS( "MenuItem.SetScriptAction"; $item; Get(FileName); REP Reports::Script ) ]
# add item to menu
Set Variable [ $r ; Value: MBS( "Menu.AddItem"; $menu; $item ) ]
End If
# next record?
Go to Record/Request/Page [ Next ; Exit after last ]
End Loop
# switch layout back
Go to Layout [ original layout ]
# Show menu
Set Variable [ $r ; Value: MBS( "Menu.PopUp"; $menu; "mouse") ]
# Cleanup memory
Set Variable [ $r ; Value: MBS( "Menu.Release"; $menu) ]
See also
- Menu.AddItems
- MenuItem.SetFontColor
- MenuItem.SetFontName
- MenuItem.SetFontSize
- MenuItem.SetItalic
- MenuItem.SetKeyEquivalent
- MenuItem.SetKeyEquivalentModifierMask
- MenuItem.SetScriptAction
- MenuItem.SetStrikeOut
- MenuItem.SetUnderline
Example Databases
Blog Entries
- Evaluate vs. Script Trigger
- Tip of the day: Build contextual menu in FileMaker from a table
- Colors for Menus in FileMaker
FileMaker Magazin
This function checks for a license.
Created 18th August 2014, last changed 11st September 2015