SyntaxColoring.AddContextMenuCommand
------------------------------------

Adds a new command for contextual menu.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [SyntaxColoring](component_SyntaxColoring.md) | [9.5](newinversion95.md) | ✅ Yes | ❌ No | ❌ No | ❌ No | ❌ No |

MBS( "SyntaxColoring.AddContextMenuCommand"; Title; Expression { ; InstallWhen; keyEquivalent; KeyEquivalentModifierMask; AvailabilityExpression } ) 

**MBS**( **"SyntaxColoring.AddContextMenuCommand";** /\* Adds a new command for contextual menu. \*/  
**$Title**; /\* The title for the menu command.  
If multi line, we build submenus based on the path descripted.  
If title is just "-", we add a separator.e.g. "MyCommands¶Hello" \*/   
**$Expression**; /\* The expression to evaluate in FileMaker when menu command is choosen. \*/   
**$InstallWhen**; /\* Optional; Whether to enable only if selection is present.  
0: always on (default)  
1: need no row selected  
2: need exactly one row selected  
3: need one or more rows selected  
4: need all rows selected  
  
Add 8 to allow for discontinuous selections (in version 10.0 or later).  
  
16: Show in browse mode.  
32: Show in layout mode.  
64: Show in Script Workspace  
  
For compatibilty we also show items in the script workspace, where none of the three flags above is set.e.g. 0 \*/   
**$keyEquivalent**; /\* Optional; The key equivalent.  
Is shown right in the menu and can be pressed while menu is open.e.g. "T" \*/   
**$KeyEquivalentModifierMask**; /\* Optional; The menu items's keyboard equivalent modifiers.  
NSShiftKeyMask is a valid modifier for any key equivalent in mask. This allows you to specify key-equivalents such as Command-Shift-1 that are consistent across all keyboards. However, with a few exceptions (such as the German "ß” character), a lowercase character with NSShiftKeyMask is interpreted the same as the uppercase character without that mask. For example, Command-Shift-c and Command-C are considered to be identical key equivalents.  
  
NSShiftKeyMask 131072 Shift Key  
NSControlKeyMask 262144 Control Key  
NSAlternateKeyMask 524288 Alternate/Option Key  
NSCommandKeyMask 1048576 Command Keye.g. 524288 + 131072 \*/   
**$AvailabilityExpression**) /\* Optional; An optional expression to calculate when building the menu.  
  
The expression needs to return a boolean.  
Return 0 to hide menu entry or 1 to show it.  
  
If the expression won't compile, we hide the menu entry.  
Trace function will log the expressions with results to help debugging.  
  
To speed up menu building, we cache results, so if multiple entries hve the same calculation, we only perform it once. \*/ 

### Parameters

| Parameter | Description | Example | Flags |
|---|---|---|---|
| Title | The title for the menu command.   If multi line, we build submenus based on the path descripted.   If title is just "-", we add a separator. | "MyCommands¶Hello" |  |
| Expression | The expression to evaluate in FileMaker when menu command is choosen. |  |  |
| InstallWhen | Whether to enable only if selection is present.   0: always on (default)   1: need no row selected   2: need exactly one row selected   3: need one or more rows selected   4: need all rows selected      Add 8 to allow for discontinuous selections (in version 10.0 or later).      16: Show in browse mode.   32: Show in layout mode.   64: Show in Script Workspace      For compatibilty we also show items in the script workspace, where none of the three flags above is set. | 0 | Optional |
| keyEquivalent | The key equivalent.   Is shown right in the menu and can be pressed while menu is open. | "T" | Optional      Added in version **10.0**. |
| KeyEquivalentModifierMask | The menu items's keyboard equivalent modifiers.   NSShiftKeyMask is a valid modifier for any key equivalent in mask. This allows you to specify key-equivalents such as Command-Shift-1 that are consistent across all keyboards. However, with a few exceptions (such as the German "ß” character), a lowercase character with NSShiftKeyMask is interpreted the same as the uppercase character without that mask. For example, Command-Shift-c and Command-C are considered to be identical key equivalents.      NSShiftKeyMask 131072 Shift Key   NSControlKeyMask 262144 Control Key   NSAlternateKeyMask 524288 Alternate/Option Key   NSCommandKeyMask 1048576 Command Key | 524288 + 131072 | Optional      Added in version **10.0**. |
| AvailabilityExpression | An optional expression to calculate when building the menu.      The expression needs to return a boolean.   Return 0 to hide menu entry or 1 to show it.      If the expression won't compile, we hide the menu entry.   Trace function will log the expressions with results to help debugging.      To speed up menu building, we cache results, so if multiple entries hve the same calculation, we only perform it once. |  | Optional      Added in version **15.1**. |

### Result

Returns OK or error.

### Description

Adds a new command for contextual menu.  
Given commands are added to contextual menu in Script Workspace when right clicking on script steps.  
Commands are stored in preferences file and can be removed via [SyntaxColoring.ClearContextMenuCommands](SyntaxColoringClearContextMenuCommands.md) function.  
  
If you use [Clipboard.GetFileMakerData](ClipboardGetFileMakerData.md) and [Clipboard.SetFileMakerData](ClipboardSetFileMakerData.md) functions, you can get the XML for the current step. You may want to use [Menubar.RunMenuCommand](MenubarRunMenuCommand.md) to run cut/copy/paste/delete commands from the FileMaker menu with the respective command IDs: 57635 for cut, 57634 for copy, 57637 for paste, 57632 for delete and 57642 for select all.  
  
Possible uses include commands  
- to add new script steps.
- to check scripts for errors.
- to search and replace things
- to add common snippets, possibly using SQL or text file functions to read the XML for them.
- to pass script steps as XML to external tools.

Use [SyntaxColoring.RemoveContextMenuCommand](SyntaxColoringRemoveContextMenuCommand.md) to remove one or [SyntaxColoring.ClearContextMenuCommands](SyntaxColoringClearContextMenuCommands.md) to clear all.  
### Examples

Add a greeting command:

 MBS ( "SyntaxColoring.AddContextMenuCommand"; "Greeting"; "MBS (\\"Msgbox\\"; \\"Hello World\\")"; 0 )  
Add a rename command for variable:

 MBS ( "SyntaxColoring.AddContextMenuCommand";   
"Rename $I to $counter ";   
"Let (\[ r = MBS ( \\"[Menubar.RunMenuCommand](MenubarRunMenuCommand.md)\\"; 57634 /\* copy \*/ ); xml = MBS ( \\"[Clipboard.GetFileMakerData](ClipboardGetFileMakerData.md)\\"; \\"ScriptStep\\" ); xml = Substitute ( xml; \\"$i \\"; \\"$counter \\"); r = MBS ( \\"[Clipboard.SetFileMakerData](ClipboardSetFileMakerData.md)\\"; \\"ScriptStep\\"; xml ); r = MBS ( \\"[Menubar.RunMenuCommand](MenubarRunMenuCommand.md)\\"; 57637 /\* paste \*/ ) \]; \\"\\" )"; 0 )  
Add an insert loop command:

 MBS ( "SyntaxColoring.AddContextMenuCommand";   
"Insert For Loop";   
"Let (\[   
xml = \\"&lt;fmxmlsnippet type=\\\\\\"FMObjectList\\\\\\"&gt;&lt;Step enable=\\\\\\"True\\\\\\" id=\\\\\\"89\\\\\\" name=\\\\\\"# (comment)\\\\\\"&gt;&lt;Text&gt;loop counting up from 1 to $count &lt;/Text&gt;&lt;/Step&gt;&lt;Step enable=\\\\\\"True\\\\\\" id=\\\\\\"141\\\\\\" name=\\\\\\"Set Variable\\\\\\"&gt;&lt;Value&gt;&lt;Calculation&gt;&lt;!\[CDATA\[\\\\\\"/\* add count here \*/\\\\\\"\]\]&gt;&lt;/Calculation&gt;&lt;/Value&gt;&lt;Repetition&gt;&lt;Calculation&gt;&lt;!\[CDATA\[1\]\]&gt;&lt;/Calculation&gt;&lt;/Repetition&gt;&lt;Name&gt;$count &lt;/Name&gt;&lt;/Step&gt;&lt;Step enable=\\\\\\"True\\\\\\" id=\\\\\\"141\\\\\\" name=\\\\\\"Set Variable\\\\\\"&gt;&lt;Value&gt;&lt;Calculation&gt;&lt;!\[CDATA\[1\]\]&gt;&lt;/Calculation&gt;&lt;/Value&gt;&lt;Repetition&gt;&lt;Calculation&gt;&lt;!\[CDATA\[1\]\]&gt;&lt;/Calculation&gt;&lt;/Repetition&gt;&lt;Name&gt;$index &lt;/Name&gt;&lt;/Step&gt;&lt;Step enable=\\\\\\"True\\\\\\" id=\\\\\\"68\\\\\\" name=\\\\\\"If\\\\\\"&gt;&lt;Calculation&gt;&lt;!\[CDATA\[$index ≤ $count \]\]&gt;&lt;/Calculation&gt;&lt;/Step&gt;&lt;Step enable=\\\\\\"True\\\\\\" id=\\\\\\"71\\\\\\" name=\\\\\\"Loop\\\\\\"&gt;&lt;/Step&gt;&lt;Step enable=\\\\\\"True\\\\\\" id=\\\\\\"89\\\\\\" name=\\\\\\"# (comment)\\\\\\"&gt;&lt;Text&gt;your script steps here&lt;/Text&gt;&lt;/Step&gt;&lt;Step enable=\\\\\\"True\\\\\\" id=\\\\\\"89\\\\\\" name=\\\\\\"# (comment)\\\\\\"&gt;&lt;/Step&gt;&lt;Step enable=\\\\\\"True\\\\\\" id=\\\\\\"89\\\\\\" name=\\\\\\"# (comment)\\\\\\"&gt;&lt;Text&gt;next&lt;/Text&gt;&lt;/Step&gt;&lt;Step enable=\\\\\\"True\\\\\\" id=\\\\\\"141\\\\\\" name=\\\\\\"Set Variable\\\\\\"&gt;&lt;Value&gt;&lt;Calculation&gt;&lt;!\[CDATA\[$index + 1\]\]&gt;&lt;/Calculation&gt;&lt;/Value&gt;&lt;Repetition&gt;&lt;Calculation&gt;&lt;!\[CDATA\[1\]\]&gt;&lt;/Calculation&gt;&lt;/Repetition&gt;&lt;Name&gt;$index &lt;/Name&gt;&lt;/Step&gt;&lt;Step enable=\\\\\\"True\\\\\\" id=\\\\\\"72\\\\\\" name=\\\\\\"Exit Loop If\\\\\\"&gt;&lt;Calculation&gt;&lt;!\[CDATA\[$index &gt; $count \]\]&gt;&lt;/Calculation&gt;&lt;/Step&gt;&lt;Step enable=\\\\\\"True\\\\\\" id=\\\\\\"73\\\\\\" name=\\\\\\"End Loop\\\\\\"&gt;&lt;/Step&gt;&lt;Step enable=\\\\\\"True\\\\\\" id=\\\\\\"70\\\\\\" name=\\\\\\"End If\\\\\\"&gt;&lt;/Step&gt;&lt;/fmxmlsnippet&gt;\\";   
r = MBS ( \\"[Clipboard.SetFileMakerData](ClipboardSetFileMakerData.md)\\"; \\"ScriptStep\\"; xml );   
r = MBS ( \\"[Menubar.RunMenuCommand](MenubarRunMenuCommand.md)\\"; 57637 /\* paste \*/ )   
\]; \\"\\" )"; 0 )  
Add a search and replace command:

 MBS ( "SyntaxColoring.AddContextMenuCommand";   
"Search and Replace";   
"Let (\[   
/\* ask for search text via dialog \*/  
ResetResult = MBS ( \\"[Dialog.Reset](DialogReset.md)\\" );  
ClearResult = MBS ( \\"[Dialog.ClearFields](DialogClearFields.md)\\" );  
MessageResult = MBS ( \\"[Dialog.SetMessage](DialogSetMessage.md)\\"; \\"Search and replace in script:\\" );  
InfoResult = MBS ( \\"[Dialog.SetInformativeText](DialogSetInformativeText.md)\\"; \\"Search text can include XML tags.\\" );  
Field1Result = MBS ( \\"[Dialog.AddField](DialogAddField.md)\\"; \\"Search for:\\" );  
Field2Result = MBS ( \\"[Dialog.AddField](DialogAddField.md)\\"; \\"Replace with:\\" );  
Button1Result = MBS ( \\"[Dialog.SetDefaultButton](DialogSetDefaultButton.md)\\"; \\"Replace\\");  
Button2Result = MBS ( \\"[Dialog.SetAlternateButton](DialogSetAlternateButton.md)\\"; \\"Cancel\\");  
DialogResult = MBS ( \\"[Dialog.Run](DialogRun.md)\\" );  
SearchText = MBS ( \\"[Dialog.GetFieldText](DialogGetFieldText.md)\\"; 0 );  
ReplaceText = MBS ( \\"[Dialog.GetFieldText](DialogGetFieldText.md)\\"; 1 );  
/\* do replace \*/  
r = If(DialogResult = \\"Replace\\"; Let(\[  
 /\* copy script steps \*/  
 r = MBS ( \\"[Menubar.RunMenuCommand](MenubarRunMenuCommand.md)\\"; 57634 );   
 /\* get XML from clipboard \*/  
 xml = MBS ( \\"[Clipboard.GetFileMakerData](ClipboardGetFileMakerData.md)\\"; \\"ScriptStep\\" );   
 /\* search and replace \*/  
 xml = Substitute ( xml; SearchText; ReplaceText);   
 /\* put XML back on clipboard \*/  
 r = MBS ( \\"[Clipboard.SetFileMakerData](ClipboardSetFileMakerData.md)\\"; \\"ScriptStep\\"; xml );   
 /\* paste script steps \*/  
 r = MBS ( \\"[Menubar.RunMenuCommand](MenubarRunMenuCommand.md)\\"; 57637 )   
\]; 1))  
\];1)"; 3 )  
Add an insert JSONSetElement command:

 MBS ( "SyntaxColoring.AddContextMenuCommand";   
"Insert set variable for JSONSetElement";   
"Let (\[   
xml = \\"&lt;fmxmlsnippet type=\\\\\\"FMObjectList\\\\\\"&gt;&lt;Step enable=\\\\\\"True\\\\\\" id=\\\\\\"141\\\\\\" name=\\\\\\"Variable setzen\\\\\\"&gt;&lt;Value&gt;&lt;Calculation&gt;&lt;!\[CDATA\[JSONSetElement ( \\" &amp; Char(10) &amp; \\" \\\\\\"{}\\\\\\" ;\\" &amp; Char(10) &amp; \\" \[ \\\\\\"keyOrIndexOrPath\\\\\\" ; \\\\\\"value\\\\\\" ; JSONString \] ;\\" &amp; Char(10) &amp; \\" \[ \\\\\\"keyOrIndexOrPath\\\\\\" ; \\\\\\"value\\\\\\" ; JSONString \]¶)\]\]&gt;&lt;/Calculation&gt;&lt;/Value&gt;&lt;Repetition&gt;&lt;Calculation&gt;&lt;!\[CDATA\[1\]\]&gt;&lt;/Calculation&gt;&lt;/Repetition&gt;&lt;Name&gt;$json &lt;/Name&gt;&lt;/Step&gt;&lt;/fmxmlsnippet&gt;\\";   
r = MBS ( \\"[Clipboard.SetFileMakerData](ClipboardSetFileMakerData.md)\\"; \\"ScriptStep\\"; xml );   
r = MBS ( \\"[Menubar.RunMenuCommand](MenubarRunMenuCommand.md)\\"; 57637 /\* paste \*/ )   
\]; \\"\\" )"; 0 )  
  
// we use Char(10) to get the new line in the XML. And we use \\\\\\ to escape quotes in escaped calculation.  
Add menu command to write script to desktop:

 MBS ( "SyntaxColoring.AddContextMenuCommand";   
"Write script to desktop";   
"MBS ( \\"[Text.WriteTextFile](TextWriteTextFile.md)\\";   
 MBS ( \\"[ScriptWorkspace.ScriptText](ScriptWorkspaceScriptText.md)\\" );   
 MBS ( \\"[Path.AddPathComponent](PathAddPathComponent.md)\\";   
 MBS ( \\"[Folders.UserDesktop](FoldersUserDesktop.md)\\" );   
 \\"Script \\" &amp; substitute(substitute(MBS ( \\"[ScriptWorkspace.CurrentTab](ScriptWorkspaceCurrentTab.md)\\" ); \\":\\"; \\"-\\"); \\"/\\"; \\"-\\") &amp; \\".txt\\" );   
 \\"UTF-8\\"   
 )"; 0 )  
Add separator item:

 MBS ( "SyntaxColoring.AddContextMenuCommand"; "-"; "-"; 0 )  
  
// needs version 10.0 of the plugin.  
Add function header:

 MBS ( "SyntaxColoring.AddContextMenuCommand";   
"Insert function header";   
"Let (\[   
xml = \\"&lt;fmxmlsnippet type=\\\\\\"FMObjectList\\\\\\"&gt;&lt;Step enable=\\\\\\"True\\\\\\" id=\\\\\\"89\\\\\\" name=\\\\\\"# (comment)\\\\\\"&gt;&lt;Text&gt;Description&lt;/Text&gt;&lt;/Step&gt;&lt;Step enable=\\\\\\"True\\\\\\" id=\\\\\\"89\\\\\\" name=\\\\\\"# (comment)\\\\\\"&gt;&lt;Text&gt;Author&lt;/Text&gt;&lt;/Step&gt;&lt;Step enable=\\\\\\"True\\\\\\" id=\\\\\\"89\\\\\\" name=\\\\\\"# (comment)\\\\\\"&gt;&lt;Text&gt;Modifications&lt;/Text&gt;&lt;/Step&gt;&lt;Step enable=\\\\\\"True\\\\\\" id=\\\\\\"89\\\\\\" name=\\\\\\"# (comment)\\\\\\"&gt;&lt;/Step&gt;&lt;Step enable=\\\\\\"True\\\\\\" id=\\\\\\"85\\\\\\" name=\\\\\\"Allow User Abort\\\\\\"&gt;&lt;Set state=\\\\\\"False\\\\\\"&gt;&lt;/Set&gt;&lt;/Step&gt;&lt;Step enable=\\\\\\"True\\\\\\" id=\\\\\\"86\\\\\\" name=\\\\\\"Set Error Capture\\\\\\"&gt;&lt;Set state=\\\\\\"True\\\\\\"&gt;&lt;/Set&gt;&lt;/Step&gt;&lt;Step enable=\\\\\\"True\\\\\\" id=\\\\\\"89\\\\\\" name=\\\\\\"# (comment)\\\\\\"&gt;&lt;/Step&gt;&lt;Step enable=\\\\\\"True\\\\\\" id=\\\\\\"141\\\\\\" name=\\\\\\"Set Variable\\\\\\"&gt;&lt;Value&gt;&lt;Calculation&gt;&lt;!\[CDATA\[Get(ScriptParameter)\]\]&gt;&lt;/Calculation&gt;&lt;/Value&gt;&lt;Repetition&gt;&lt;Calculation&gt;&lt;!\[CDATA\[1\]\]&gt;&lt;/Calculation&gt;&lt;/Repetition&gt;&lt;Name&gt;$param &lt;/Name&gt;&lt;/Step&gt;&lt;Step enable=\\\\\\"True\\\\\\" id=\\\\\\"89\\\\\\" name=\\\\\\"# (comment)\\\\\\"&gt;&lt;/Step&gt;&lt;Step enable=\\\\\\"True\\\\\\" id=\\\\\\"89\\\\\\" name=\\\\\\"# (comment)\\\\\\"&gt;&lt;/Step&gt;&lt;Step enable=\\\\\\"True\\\\\\" id=\\\\\\"89\\\\\\" name=\\\\\\"# (comment)\\\\\\"&gt;&lt;/Step&gt;&lt;Step enable=\\\\\\"True\\\\\\" id=\\\\\\"141\\\\\\" name=\\\\\\"Set Variable\\\\\\"&gt;&lt;Value&gt;&lt;Calculation&gt;&lt;!\[CDATA\[\\\\\\"\\\\\\"\]\]&gt;&lt;/Calculation&gt;&lt;/Value&gt;&lt;Repetition&gt;&lt;Calculation&gt;&lt;!\[CDATA\[1\]\]&gt;&lt;/Calculation&gt;&lt;/Repetition&gt;&lt;Name&gt;$result &lt;/Name&gt;&lt;/Step&gt;&lt;Step enable=\\\\\\"True\\\\\\" id=\\\\\\"103\\\\\\" name=\\\\\\"Exit Script\\\\\\"&gt;&lt;Calculation&gt;&lt;!\[CDATA\[$result \]\]&gt;&lt;/Calculation&gt;&lt;/Step&gt;&lt;/fmxmlsnippet&gt;\\";   
r = MBS ( \\"[Clipboard.SetFileMakerData](ClipboardSetFileMakerData.md)\\"; \\"ScriptStep\\"; xml );   
r = MBS ( \\"[Menubar.RunMenuCommand](MenubarRunMenuCommand.md)\\"; 57637 /\* paste \*/ )   
\]; \\"\\" )"; 0 )  
Add command to paste snippet from folder picked by dialog:

 MBS ( "SyntaxColoring.AddContextMenuCommand";   
"Insert snippet from snippet folder";   
"Let(\[  
Path = MBS ( \\"[Path.AddPathComponent](PathAddPathComponent.md)\\"; MBS ( \\"[Folders.UserHome](FoldersUserHome.md)\\" ); \\"Library\\"; \\"Application Support\\"; \\"FileMaker\\"; \\"Snippets\\");  
Files = MBS ( \\"[Files.List](FilesList.md)\\"; Path; 1+4);  
Names = MBS ( \\"[List.RemovePostfix](ListRemovePostfix.md)\\"; Files; \\".xml\\"; 1);  
r = MBS ( \\"[ListDialog.Reset](ListDialogReset.md)\\" ) &amp; MBS ( \\"[ListDialog.AddItemsToList](ListDialogAddItemsToList.md)\\"; Names; Files) &amp; MBS ( \\"[ListDialog.SetPrompt](ListDialogSetPrompt.md)\\"; \\"Choose snippet to insert:\\" );  
answer = MBS ( \\"[ListDialog.ShowDialog](ListDialogShowDialog.md)\\" );  
r = If(answer = \\"OK\\"; MBS ( \\"[Clipboard.SetFileMakerData](ClipboardSetFileMakerData.md)\\"; \\"ScriptStep\\"; MBS ( \\"[Text.ReadTextFile](TextReadTextFile.md)\\"; MBS ( \\"[Path.AddPathComponent](PathAddPathComponent.md)\\"; Path; MBS ( \\"[ListDialog.GetSelectedTag](ListDialogGetSelectedTag.md)\\" )); \\"UTF-8\\") ) &amp; MBS ( \\"[Menubar.RunMenuCommand](MenubarRunMenuCommand.md)\\"; 57637 /\* paste \*/ ))\]; 0)"; 0 )  
  
// put snippets as xml files into ~/Library/Application Support/FileMaker/Snippets folder.  
Add duplicate context menu entry:

 MBS ( "SyntaxColoring.AddContextMenuCommand"; "Duplicate";   
"Let (\[ r = MBS ( \\"[Menubar.RunMenuCommand](MenubarRunMenuCommand.md)\\"; 49182 /\* duplicate \*/ )\]; \\"\\" )"; 3 )  
Add a menu command to print contact, which only shows up if we have primary key for contacts:

 MBS ( "SyntaxColoring.AddContextMenuCommand";   
"Print Contact";   
"MBS (\\"[FM.RunScript](FMRunScript.md)\\"; \\"Contacts\\"; \\"Print Contact\\")"; // run a script  
16; // show in browse mode  
""; "";   
"Not IsEmpty(Contacts::Primary Key)" )  
// if current layout has no relationship to contacts, this errors and the menu entry doesn't show.  
### See also

- [ListDialog.AddItemsToList](ListDialogAddItemsToList.md)
- [ListDialog.GetSelectedTag](ListDialogGetSelectedTag.md)
- [ListDialog.SetPrompt](ListDialogSetPrompt.md)
- [ListDialog.ShowDialog](ListDialogShowDialog.md)
- [Menubar.RunMenuCommand](MenubarRunMenuCommand.md)
- [ScriptWorkspace.CurrentTab](ScriptWorkspaceCurrentTab.md)
- [SyntaxColoring.Clear](SyntaxColoringClear.md)
- [SyntaxColoring.ClearContextMenuCommands](SyntaxColoringClearContextMenuCommands.md)
- [SyntaxColoring.ListContextMenuCommand](SyntaxColoringListContextMenuCommand.md)
- [SyntaxColoring.RemoveContextMenuCommand](SyntaxColoringRemoveContextMenuCommand.md)

### Release notes

- **Version 15.1**
    - Added AvailabilityExpression parameter to [SyntaxColoring.AddContextMenuCommand](https://www.mbsplugins.eu/SyntaxColoringAddContextMenuCommand.shtml) function.
    - Fixed memory issue for [SyntaxColoring.AddContextMenuCommand](https://www.mbsplugins.eu/SyntaxColoringAddContextMenuCommand.shtml) causing crashes.
    - Improved [SyntaxColoring.AddContextMenuCommand](https://www.mbsplugins.eu/SyntaxColoringAddContextMenuCommand.shtml) to add entries to the menu, if you have a spelling suggestion.
    - Improved [SyntaxColoring.AddContextMenuCommand](https://www.mbsplugins.eu/SyntaxColoringAddContextMenuCommand.shtml) to better detect layout vs. browse mode.
- **Version 15.0**
    - Improved [SyntaxColoring.AddContextMenuCommand](https://www.mbsplugins.eu/SyntaxColoringAddContextMenuCommand.shtml) function to allow them to show in browse and layout mode.
- **Version 10.0**
    - Added keyEquivalent and KeyEquivalentModifierMask parameters to [SyntaxColoring.AddContextMenuCommand](https://www.mbsplugins.eu/SyntaxColoringAddContextMenuCommand.shtml) function.
    - Added option for [SyntaxColoring.AddContextMenuCommand](https://www.mbsplugins.eu/SyntaxColoringAddContextMenuCommand.shtml) to create separator items.
    - Added option to [SyntaxColoring.AddContextMenuCommand](https://www.mbsplugins.eu/SyntaxColoringAddContextMenuCommand.shtml) to mark whether a command can work with discontinuous selections.
- **Version 9.5**
    - Added [SyntaxColoring.AddContextMenuCommand](http://www.mbsplugins.eu/SyntaxColoringAddContextMenuCommand.shtml), [SyntaxColoring.ClearContextMenuCommands](http://www.mbsplugins.eu/SyntaxColoringClearContextMenuCommands.shtml) and [SyntaxColoring.RemoveContextMenuCommand](http://www.mbsplugins.eu/SyntaxColoringRemoveContextMenuCommand.shtml) functions.

### Example Databases

- [Mac only/Script Workspace Context Menu Commands](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Mac%20only/Script%20Workspace%20Context%20Menu%20Commands.shtml#1ScriptAnchor_)

### Blog Entries

- [Goodies 33: Custom context menu commands for FileMaker ScriptWorkspace](https://www.monkeybreadsoftware.com/filemaker/SyntaxColoring/33-CustomcontextmenucommandsforFileMakerScriptWorkspace.shtml)
- [MBS Plugin 15.1 for Claris FileMaker](https://www.mbsplugins.de/archive/2025-03-11/MBS_Plugin_151_for_Claris_File/monkeybreadsoftware_blog_filemaker)
- [MBS Plugin 15.0 for Claris FileMaker](https://www.mbsplugins.de/archive/2025-01-14/MBS_Plugin_150_for_Claris_File/monkeybreadsoftware_blog_filemaker)
- [Extend the context menu for layout and browse mode in FileMaker](https://www.mbsplugins.de/archive/2024-12-11/Extend_the_context_menu_for_la/monkeybreadsoftware_blog_filemaker)
- [Adding ChatGPT to the ScriptWorkspace context menu](https://www.mbsplugins.de/archive/2024-09-18/Adding_ChatGPT_to_the_ScriptWo/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin 10.0 - More than 6000 Functions In One Plugin](https://www.mbsplugins.de/archive/2020-01-14/MBS_FileMaker_Plugin_100_-_Mor/monkeybreadsoftware_blog_filemaker)
- [Formatting and error checking expressions in FileMaker](https://www.mbsplugins.de/archive/2019-12-06/Formatting_and_error_checking_/monkeybreadsoftware_blog_filemaker)
- [New functions of the MBS Plugin Version 9.5](https://www.mbsplugins.de/archive/2019-11-21/New_functions_of_the_MBS_Plugi/monkeybreadsoftware_blog_filemaker)
- [Insert snippet for FileMaker on Windows](https://www.mbsplugins.de/archive/2019-11-20/Insert_snippet_for_FileMaker_o/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin 9.5 video](https://www.mbsplugins.de/archive/2019-11-15/MBS_FileMaker_Plugin_95_video/monkeybreadsoftware_blog_filemaker)

### FileMaker Magazin

- [Ausgabe 6/2020, Seite 29](https://filemaker-magazin.de/neuigkeit/4118-Appetithappen-FMM_202006)

This function is free to use.

Created 18th October 2019 , last changed 25th February 2026

  
[StoreRegistration](StoreRegistration.md) - [SyntaxColoring.AddCustomFunctionTooltip](SyntaxColoringAddCustomFunctionTooltip.md)

[HTML Version](SyntaxColoringAddContextMenuCommand.shtml)