TouchBar.AddButton
------------------

Adds a simple button.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [TouchBar](component_TouchBar.md) | [6.5](newinversion65.md) | ✅ Yes | ❌ No | ❌ No | ❌ No | ❌ No |

MBS( "TouchBar.AddButton"; TouchBarRef; Identifier; Text; Image; CustomizationLabel; visibilityPriority { ; FileName; ScriptName; Expression } ) 

**MBS**( **"TouchBar.AddButton";** /\* Adds a simple button. \*/  
**$TouchBarRef**; /\* The reference number for the touch bar.e.g. $TouchBar \*/   
**$Identifier**; /\* The identifier for the new item.e.g. "com.yourdomain.send" \*/   
**$Text**; /\* The text of the button.  
Can be empty to show no text.e.g. "Send" \*/   
**$Image**; /\* The image of the button.  
Pass container here with PNG for best result. JPEG may not work due to missing transparency.  
Can be one of the following texts to pick a default image:  
NSImageNameTouchBarAddDetailTemplate, NSImageNameTouchBarAddTemplate, NSImageNameTouchBarAlarmTemplate, NSImageNameTouchBarAudioInputMuteTemplate, NSImageNameTouchBarAudioInputTemplate, NSImageNameTouchBarAudioOutputMuteTemplate, NSImageNameTouchBarAudioOutputVolumeHighTemplate, NSImageNameTouchBarAudioOutputVolumeLowTemplate, NSImageNameTouchBarAudioOutputVolumeMediumTemplate, NSImageNameTouchBarAudioOutputVolumeOffTemplate, NSImageNameTouchBarBookmarksTemplate, NSImageNameTouchBarColorPickerFill, NSImageNameTouchBarColorPickerFont, NSImageNameTouchBarColorPickerStroke, NSImageNameTouchBarCommunicationAudioTemplate, NSImageNameTouchBarCommunicationVideoTemplate, NSImageNameTouchBarComposeTemplate, NSImageNameTouchBarDeleteTemplate, NSImageNameTouchBarDownloadTemplate, NSImageNameTouchBarEnterFullScreenTemplate, NSImageNameTouchBarExitFullScreenTemplate, NSImageNameTouchBarFastForwardTemplate, NSImageNameTouchBarFolderCopyToTemplate, NSImageNameTouchBarFolderMoveToTemplate, NSImageNameTouchBarFolderTemplate, NSImageNameTouchBarGetInfoTemplate, NSImageNameTouchBarGoBackTemplate, NSImageNameTouchBarGoDownTemplate, NSImageNameTouchBarGoForwardTemplate, NSImageNameTouchBarGoUpTemplate, NSImageNameTouchBarHistoryTemplate, NSImageNameTouchBarIconViewTemplate, NSImageNameTouchBarListViewTemplate, NSImageNameTouchBarMailTemplate, NSImageNameTouchBarNewFolderTemplate, NSImageNameTouchBarNewMessageTemplate, NSImageNameTouchBarOpenInBrowserTemplate, NSImageNameTouchBarPauseTemplate, NSImageNameTouchBarPlayheadTemplate, NSImageNameTouchBarPlayPauseTemplate, NSImageNameTouchBarPlayTemplate, NSImageNameTouchBarQuickLookTemplate, NSImageNameTouchBarRecordStartTemplate, NSImageNameTouchBarRecordStopTemplate, NSImageNameTouchBarRefreshTemplate, NSImageNameTouchBarRewindTemplate, NSImageNameTouchBarRotateLeftTemplate, NSImageNameTouchBarRotateRightTemplate, NSImageNameTouchBarSearchTemplate, NSImageNameTouchBarShareTemplate, NSImageNameTouchBarSidebarTemplate, NSImageNameTouchBarSkipAhead15SecondsTemplate, NSImageNameTouchBarSkipAhead30SecondsTemplate, NSImageNameTouchBarSkipAheadTemplate, NSImageNameTouchBarSkipBack15SecondsTemplate, NSImageNameTouchBarSkipBack30SecondsTemplate, NSImageNameTouchBarSkipBackTemplate, NSImageNameTouchBarSkipToEndTemplate, NSImageNameTouchBarSkipToStartTemplate, NSImageNameTouchBarSlideshowTemplate, NSImageNameTouchBarTagIconTemplate, NSImageNameTouchBarTextBoldTemplate, NSImageNameTouchBarTextBoxTemplate, NSImageNameTouchBarTextCenterAlignTemplate, NSImageNameTouchBarTextItalicTemplate, NSImageNameTouchBarTextJustifiedAlignTemplate, NSImageNameTouchBarTextLeftAlignTemplate, NSImageNameTouchBarTextListTemplate, NSImageNameTouchBarTextRightAlignTemplate, NSImageNameTouchBarTextStrikethroughTemplate, NSImageNameTouchBarTextUnderlineTemplate, NSImageNameTouchBarUserAddTemplate, NSImageNameTouchBarUserGroupTemplate, NSImageNameTouchBarUserTemplate, NSImageNameTouchBarVolumeDownTemplate or NSImageNameTouchBarVolumeUpTemplate.e.g. "NSImageNameTouchBarMailTemplate" \*/   
**$CustomizationLabel**; /\* The customization label.e.g. "Send Email" \*/   
**$visibilityPriority**; /\* The visibility priority.  
Ranges from -1000 for low to 1000 for high.e.g. 0 \*/   
**$FileName**; /\* Optional; The file name where the script is stored.e.g. Get(FileName) \*/   
**$ScriptName**; /\* Optional; The script name (or ID) to trigger when button is used.  
Parameter to the script is the identifier.e.g. "TouchBar SendEmail" \*/   
**$Expression**) /\* Optional; An expression to execute when button is pressed.e.g. "" \*/ 

### Parameters

| Parameter | Description | Example | Flags |
|---|---|---|---|
| TouchBarRef | The reference number for the touch bar. | $TouchBar |  |
| Identifier | The identifier for the new item. | "com.yourdomain.send" |  |
| Text | The text of the button.   Can be empty to show no text. | "Send" |  |
| Image | The image of the button.   Pass container here with PNG for best result. JPEG may not work due to missing transparency.   Can be one of the following texts to pick a default image:   NSImageNameTouchBarAddDetailTemplate, NSImageNameTouchBarAddTemplate, NSImageNameTouchBarAlarmTemplate, NSImageNameTouchBarAudioInputMuteTemplate, NSImageNameTouchBarAudioInputTemplate, NSImageNameTouchBarAudioOutputMuteTemplate, NSImageNameTouchBarAudioOutputVolumeHighTemplate, NSImageNameTouchBarAudioOutputVolumeLowTemplate, NSImageNameTouchBarAudioOutputVolumeMediumTemplate, NSImageNameTouchBarAudioOutputVolumeOffTemplate, NSImageNameTouchBarBookmarksTemplate, NSImageNameTouchBarColorPickerFill, NSImageNameTouchBarColorPickerFont, NSImageNameTouchBarColorPickerStroke, NSImageNameTouchBarCommunicationAudioTemplate, NSImageNameTouchBarCommunicationVideoTemplate, NSImageNameTouchBarComposeTemplate, NSImageNameTouchBarDeleteTemplate, NSImageNameTouchBarDownloadTemplate, NSImageNameTouchBarEnterFullScreenTemplate, NSImageNameTouchBarExitFullScreenTemplate, NSImageNameTouchBarFastForwardTemplate, NSImageNameTouchBarFolderCopyToTemplate, NSImageNameTouchBarFolderMoveToTemplate, NSImageNameTouchBarFolderTemplate, NSImageNameTouchBarGetInfoTemplate, NSImageNameTouchBarGoBackTemplate, NSImageNameTouchBarGoDownTemplate, NSImageNameTouchBarGoForwardTemplate, NSImageNameTouchBarGoUpTemplate, NSImageNameTouchBarHistoryTemplate, NSImageNameTouchBarIconViewTemplate, NSImageNameTouchBarListViewTemplate, NSImageNameTouchBarMailTemplate, NSImageNameTouchBarNewFolderTemplate, NSImageNameTouchBarNewMessageTemplate, NSImageNameTouchBarOpenInBrowserTemplate, NSImageNameTouchBarPauseTemplate, NSImageNameTouchBarPlayheadTemplate, NSImageNameTouchBarPlayPauseTemplate, NSImageNameTouchBarPlayTemplate, NSImageNameTouchBarQuickLookTemplate, NSImageNameTouchBarRecordStartTemplate, NSImageNameTouchBarRecordStopTemplate, NSImageNameTouchBarRefreshTemplate, NSImageNameTouchBarRewindTemplate, NSImageNameTouchBarRotateLeftTemplate, NSImageNameTouchBarRotateRightTemplate, NSImageNameTouchBarSearchTemplate, NSImageNameTouchBarShareTemplate, NSImageNameTouchBarSidebarTemplate, NSImageNameTouchBarSkipAhead15SecondsTemplate, NSImageNameTouchBarSkipAhead30SecondsTemplate, NSImageNameTouchBarSkipAheadTemplate, NSImageNameTouchBarSkipBack15SecondsTemplate, NSImageNameTouchBarSkipBack30SecondsTemplate, NSImageNameTouchBarSkipBackTemplate, NSImageNameTouchBarSkipToEndTemplate, NSImageNameTouchBarSkipToStartTemplate, NSImageNameTouchBarSlideshowTemplate, NSImageNameTouchBarTagIconTemplate, NSImageNameTouchBarTextBoldTemplate, NSImageNameTouchBarTextBoxTemplate, NSImageNameTouchBarTextCenterAlignTemplate, NSImageNameTouchBarTextItalicTemplate, NSImageNameTouchBarTextJustifiedAlignTemplate, NSImageNameTouchBarTextLeftAlignTemplate, NSImageNameTouchBarTextListTemplate, NSImageNameTouchBarTextRightAlignTemplate, NSImageNameTouchBarTextStrikethroughTemplate, NSImageNameTouchBarTextUnderlineTemplate, NSImageNameTouchBarUserAddTemplate, NSImageNameTouchBarUserGroupTemplate, NSImageNameTouchBarUserTemplate, NSImageNameTouchBarVolumeDownTemplate or NSImageNameTouchBarVolumeUpTemplate. | "NSImageNameTouchBarMailTemplate" |  |
| CustomizationLabel | The customization label. | "Send Email" |  |
| visibilityPriority | The visibility priority.   Ranges from -1000 for low to 1000 for high. | 0 |  |
| FileName | The file name where the script is stored. | Get(FileName) | Optional |
| ScriptName | The script name (or ID) to trigger when button is used.   Parameter to the script is the identifier. | "TouchBar SendEmail" | Optional |
| Expression | An expression to execute when button is pressed. | "" | Optional |

### Result

Returns OK or error.

### Description

Adds a simple button.  
### Examples

Add a back button:

 Set Variable \[ $r ; Value: MBS ( "TouchBar.AddButton"; $t ; "PrevRecord"; ""; "NSImageNameTouchBarGoBackTemplate"; "Previous"; 0; Get(FileName); "PrevRecordTouchBar" ) \]  
Add a next button:

 Set Variable \[ $r ; Value: MBS ( "TouchBar.AddButton"; $t ; "NextRecord"; ""; "NSImageNameTouchBarGoForwardTemplate"; "Previous"; 0; Get(FileName); "NextRecordTouchBar" ) \]  
Add a plus button:

 Set Variable \[ $r ; Value: MBS ( "TouchBar.AddButton"; $t ; "AddRecord"; ""; "NSImageNameTouchBarAddTemplate"; "Add"; 0; Get(FileName); "AddRecordTouchBar" ) \]  
Add a delete button:

 Set Variable \[ $r ; Value: MBS ( "TouchBar.AddButton"; $t ; "DeleteRecord"; ""; "NSImageNameTouchBarDeleteTemplate"; "Delete"; 0; Get(FileName); "DeleteRecordTouchBar" ) \]  
Add button to trigger data viewer:

 Set Variable \[ $r ; Value: MBS ( "TouchBar.AddButton"; $t ; "DataViewerButton"; "DataViewer"; ""; "DataViewer"; 0; ""; ""; "MBS (\\"[Menubar.RunMenuCommand](MenubarRunMenuCommand.md)\\"; 49297)" ) \]  
Add button to trigger debugger:

 Set Variable \[ $r ; Value: MBS ( "TouchBar.AddButton"; $t ; "DebuggerButton"; "Debugger"; ""; "Debugger"; 0; ""; ""; "MBS (\\"[Menubar.RunMenuCommand](MenubarRunMenuCommand.md)\\"; 49260)" ) \]  
### See also

- [Menubar.RunMenuCommand](MenubarRunMenuCommand.md)
- [TouchBar.AssignToApp](TouchBarAssignToApp.md)
- [TouchBar.AssignToWindow](TouchBarAssignToWindow.md)

### Example Databases

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

### Blog Entries

- [MBS FileMaker Plugin, version 6.5pr9](https://www.mbsplugins.de/archive/2016-12-05/MBS_FileMaker_Plugin_version_6/monkeybreadsoftware_blog_filemaker)

This function checks for a license.

Created 1st November 2016 , last changed 17th July 2022

  
[Toolbar.Unregister](ToolbarUnregister.md) - [TouchBar.AssignToApp](TouchBarAssignToApp.md)

[HTML Version](TouchBarAddButton.shtml)