Components All New MacOS Windows Linux iOS
Examples Mac & Win Server Client Guides Statistic FMM Blog Deprecated Old

Menu.SelectedItem

Returns the reference number of the selected menu item.

Component Version macOS Windows Linux Server iOS SDK
Menu 4.1 ✅ Yes ✅ Yes ❌ No ❌ No ❌ No
MBS( "Menu.SelectedItem"; menu )   More

Parameters

Parameter Description Example
menu The reference to the menu. Please create one with Menu.CreateMenu. $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")]
# create menu items...
Set Variable [$item; Value:MBS("MenuItem.CreateMenuItem"; "Hello World")]
Set Variable [$r; Value:MBS("MenuItem.SetTag"; $item; "secret value")]
Set Variable [$r; Value:MBS("Menu.AddItem"; $menu; $item)]
#
#show menu
Set Variable [$m; Value:MBS("Menu.PopUp"; $Menu; "mouse")]
#
#you selected something?
If [$m = 1]
    Set Variable [$selectedItem; Value:MBS("Menu.SelectedItem"; $menu)]
    Set Variable [$selectedTitle; Value:MBS("MenuItem.GetTitle"; $selectedItem)]
    Set Variable [$selectedTag; Value:MBS("MenuItem.GetTag"; $selectedItem)]
    #
    Show Custom Dialog ["Auswahl"; $selectedItem & ¶ & $selectedTitle & ¶ & $selectedTag]
End If
Set Variable [$m; Value:MBS("Menu.Release"; $Menu; 1)]

Choose from menu with one Let statement:

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

See also

Example Databases

Blog Entries

This function checks for a license.

Created 18th August 2014, last changed 18th June 2016


Menu.RemoveItemAtIndex - Menu.SetAllowsContextMenuPlugIns