Menu.SelectedItem
-----------------

Returns the reference number of the selected menu item.

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

MBS( "Menu.SelectedItem"; menu ) 

**MBS**( **"Menu.SelectedItem";** /\* Returns the reference number of the selected menu item. \*/  
**$menu**) /\* The reference to the menu. Please create one with [Menu.CreateMenu](MenuCreateMenu.md). \*/ 

### Parameters

| Parameter | Description | Example |
|---|---|---|
| menu | The reference to the menu. Please create one with [Menu.CreateMenu](MenuCreateMenu.md). | $menu |

### Result

Returns reference number or error.

### Description

Returns the reference number of the selected menu item.  
### Examples

Show menu and show selection:

 Set Variable \[$menu ; Value:MBS ("[Menu.CreateMenu](MenuCreateMenu.md)")\]  
\# create menu items...   
Set Variable \[$item ; Value:MBS ("[MenuItem.CreateMenuItem](MenuItemCreateMenuItem.md)"; "Hello World")\]  
Set Variable \[$r ; Value:MBS ("[MenuItem.SetTag](MenuItemSetTag.md)"; $item ; "secret value")\]  
Set Variable \[$r ; Value:MBS ("[Menu.AddItem](MenuAddItem.md)"; $menu ; $item )\]  
\#   
\#show menu   
Set Variable \[$m ; Value:MBS ("[Menu.PopUp](MenuPopUp.md)"; $Menu ; "mouse")\]  
\#   
\#you selected something?   
If \[$m = 1\]  
 Set Variable \[$selectedItem ; Value:MBS ("Menu.SelectedItem"; $menu )\]  
 Set Variable \[$selectedTitle ; Value:MBS ("[MenuItem.GetTitle](MenuItemGetTitle.md)"; $selectedItem )\]  
 Set Variable \[$selectedTag ; Value:MBS ("[MenuItem.GetTag](MenuItemGetTag.md)"; $selectedItem )\]  
 #  
 Show Custom Dialog \["Auswahl"; $selectedItem &amp; ¶ &amp; $selectedTitle &amp; ¶ &amp; $selectedTag \]  
End If  
Set Variable \[$m ; Value:MBS ("[Menu.Release](MenuRelease.md)"; $Menu ; 1)\]  
Choose from menu with one Let statement:

 Let ( \[   
// show menu with one let statement  
  
// some list of menu entries  
valuelist = "xxx¶yyy¶zzz" ;  
// create menu from definition  
menu = MBS ( "[Menu.DefineQuickMenu](MenuDefineQuickMenu.md)"; "x" ; valuelist ) ;  
// show menu near mouse  
result = MBS ( "[Menu.PopUp](MenuPopUp.md)" ; menu ; "mouse" ) ;  
// query selected item number  
item = IF ( result = 1 ; MBS ("Menu.SelectedItem"; menu) ) ;  
// query title for that item  
title = IF ( Length ( item &gt; 0 ) ; MBS ( "[MenuItem.GetTitle](MenuItemGetTitle.md)" ; item ) ) ;  
// release memory  
r = MBS ( "[Menu.Release](MenuRelease.md)"; menu ) \] ;   
// return the selected title  
title )  
### See also

- [Menu.AddItem](MenuAddItem.md)
- [Menu.AddItems](MenuAddItems.md)
- [Menu.CreateMenu](MenuCreateMenu.md)
- [Menu.DefineQuickMenu](MenuDefineQuickMenu.md)
- [Menu.PopUp](MenuPopUp.md)
- [Menu.Release](MenuRelease.md)
- [MenuItem.CreateMenuItem](MenuItemCreateMenuItem.md)
- [MenuItem.GetTag](MenuItemGetTag.md)
- [MenuItem.GetTitle](MenuItemGetTitle.md)
- [MenuItem.SetTag](MenuItemSetTag.md)

### Example Databases

- [Menu/DefineQuickMenu with XML](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Menu/DefineQuickMenu%20with%20XML.shtml#1ScriptAnchor_)
- [Menu/DefineQuickMenu](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Menu/DefineQuickMenu.shtml#1ScriptAnchor_)

### Blog Entries

- [QuickMenu function](https://www.mbsplugins.de/archive/2014-12-01/QuickMenu_function/monkeybreadsoftware_blog_filemaker)
- [MBS Filemaker Plugin, version 4.5pr2](https://www.mbsplugins.de/archive/2014-12-01/MBS_Filemaker_Plugin_version_4/monkeybreadsoftware_blog_filemaker)

### FileMaker Magazin

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

This function checks for a license.

Created 18th August 2014 , last changed 5th September 2025

  
[Menu.RemoveItemAtIndex](MenuRemoveItemAtIndex.md) - [Menu.SetAllowsContextMenuPlugIns](MenuSetAllowsContextMenuPlugIns.md)

[HTML Version](MenuSelectedItem.shtml)