MenuItem.CreateMenuItem
-----------------------

Creates a new menu item.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [Menu](component_Menu.md) | [4.1](newinversion41.md) | ✅ Yes | ✅ Yes | ❌ No | ❌ No | ❌ No |

MBS( "MenuItem.CreateMenuItem" { ; Title; keyEquivalent } ) 

**MBS**( **"MenuItem.CreateMenuItem";** /\* Creates a new menu item. \*/  
**$Title**; /\* Optional; The title of the menu item.e.g. "Hello World" \*/   
**$keyEquivalent**) /\* Optional; Optional, a string representing a keyboard key to be used as the key equivalent.e.g. "T" \*/ 

### Parameters

| Parameter | Description | Example | Flags |
|---|---|---|---|
| Title | The title of the menu item. | "Hello World" | Optional |
| keyEquivalent | Optional, a string representing a keyboard key to be used as the key equivalent. | "T" | Optional |

### Result

Returns menu item reference number or error.

### Description

Creates a new menu item.  
You later need to release it with [MenuItem.Release](MenuItemRelease.md).  
Menu item reference numbers are starting at 11000 and counting up for each new menu item.  
### 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](MenuCreateMenu.md)") \]   
\# 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](MenuItemSetScriptAction.md)"; $item ; Get(FileName); REP Reports::Script ) \]   
 # add item to menu  
 Set Variable \[ $r ; Value: MBS ( "[Menu.AddItem](MenuAddItem.md)"; $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](MenuPopUp.md)"; $menu ; "mouse") \]   
\# Cleanup memory   
Set Variable \[ $r ; Value: MBS ( "[Menu.Release](MenuRelease.md)"; $menu ) \]  
### See also

- [MenuItem.SetRequireCommand](MenuItemSetRequireCommand.md)
- [MenuItem.SetRequireOption](MenuItemSetRequireOption.md)
- [MenuItem.SetRequireShift](MenuItemSetRequireShift.md)
- [MenuItem.SetState](MenuItemSetState.md)
- [MenuItem.SetStrikeOut](MenuItemSetStrikeOut.md)
- [MenuItem.SetSubMenu](MenuItemSetSubMenu.md)
- [MenuItem.SetTag](MenuItemSetTag.md)
- [MenuItem.SetTitle](MenuItemSetTitle.md)
- [MenuItem.SetToolTip](MenuItemSetToolTip.md)
- [MenuItem.SetURL](MenuItemSetURL.md)

### Example Databases

- [Mac and iOS/Data Detector](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Mac%20and%20iOS/Data%20Detector.shtml#2ScriptAnchor_)
- [Menu/Popup Menu](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Menu/Popup%20Menu.shtml#2ScriptAnchor_)

### Blog Entries

- [Evaluate vs. Script Trigger](https://www.mbsplugins.de/archive/2016-03-04/Evaluate_vs_Script_Trigger/monkeybreadsoftware_blog_filemaker)
- [Tip of the day: Build contextual menu in FileMaker from a table](https://www.mbsplugins.de/archive/2015-09-11/Tip_of_the_day_Build_contextua/monkeybreadsoftware_blog_filemaker)
- [Colors for Menus in FileMaker](https://www.mbsplugins.de/archive/2015-05-02/Colors_for_Menus_in_FileMaker/monkeybreadsoftware_blog_filemaker)

### FileMaker Magazin

- [Ausgabe 2/2021, Seite 28 bis 30](https://filemaker-magazin.de/neuigkeit/4132-Appetithappen-FMM_202102)

This function checks for a license.

Created 18th August 2014 , last changed 11st September 2015

  
[Menu.SetURL](MenuSetURL.md) - [MenuItem.CreateSeparator](MenuItemCreateSeparator.md)

[HTML Version](MenuItemCreateMenuItem.shtml)