TouchBar.AssignToWindow
-----------------------

Assigns the TouchBar to be the one used with the given window.

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

MBS( "TouchBar.AssignToWindow"; TouchBarRef; WindowRef ) 

**MBS**( **"TouchBar.AssignToWindow";** /\* Assigns the TouchBar to be the one used with the given window. \*/  
**$TouchBarRef**; /\* The reference number for the touch bar.e.g. $TouchBar \*/   
**$WindowRef**) /\* Window Reference is the unique OS level window ID. You can obtain this by using the [Window.FindByTitle](WindowFindByTitle.md) or [Window.FindByIndex](WindowFindByIndex.md) functions. Pass zero to access the frontmost window.e.g. 0 \*/ 

### Parameters

| Parameter | Description | Example |
|---|---|---|
| TouchBarRef | The reference number for the touch bar. | $TouchBar |
| WindowRef | Window Reference is the unique OS level window ID. You can obtain this by using the [Window.FindByTitle](WindowFindByTitle.md) or [Window.FindByIndex](WindowFindByIndex.md) functions. Pass zero to access the frontmost window. | 0 |

### Result

Returns OK or error.

### Description

Assigns the TouchBar to be the one used with the given window.  
### Examples

Build TouchBar for Window:

 #Create a new TouchBar   
Set Variable \[$t ; Value:MBS ( "[TouchBar.Create](TouchBarCreate.md)" )\]  
\#Add two buttons   
Set Variable \[$r ; Value:MBS ( "[TouchBar.AddButton](TouchBarAddButton.md)"; $t ; "PrevRecord"; ""; "NSImageNameTouchBarGoBackTemplate"; "Previous"; 0; Get(FileName); "PrevRecordTouchBar" )\]  
Set Variable \[$r ; Value:MBS ( "[TouchBar.AddButton](TouchBarAddButton.md)"; $t ; "NextRecord"; ""; "NSImageNameTouchBarGoForwardTemplate"; "Previous"; 0; Get(FileName); "NextRecordTouchBar" )\]  
\#Set which button show by default:   
Set Variable \[$r ; Value:MBS ( "[TouchBar.SetDefaultItemIdentifiers](TouchBarSetDefaultItemIdentifiers.md)"; $t ; "PrevRecord¶NextRecord¶NSTouchBarItemIdentifierOtherItemsProxy")\]  
\#Set the primary button:   
Set Variable \[$r ; Value:MBS ( "[TouchBar.SetPrincipalItemIdentifier](TouchBarSetPrincipalItemIdentifier.md)"; $t ; "NextRecord" )\]  
\#Set which buttons can be configured:   
Set Variable \[$r ; Value:MBS ( "[TouchBar.SetCustomizationAllowedItemIdentifiers](TouchBarSetCustomizationAllowedItemIdentifiers.md)"; $t ; "PrevRecord¶NextRecord")\]  
\#Assign touchbar to current window:   
Set Variable \[$r ; Value:MBS ( "TouchBar.AssignToWindow"; $t ; 0 )\]  
### See also

- [TouchBar.AddButton](TouchBarAddButton.md)
- [TouchBar.Create](TouchBarCreate.md)
- [TouchBar.SetCustomizationAllowedItemIdentifiers](TouchBarSetCustomizationAllowedItemIdentifiers.md)
- [TouchBar.SetDefaultItemIdentifiers](TouchBarSetDefaultItemIdentifiers.md)
- [TouchBar.SetPrincipalItemIdentifier](TouchBarSetPrincipalItemIdentifier.md)
- [Window.ClearTouchBar](WindowClearTouchBar.md)
- [Window.FindByIndex](WindowFindByIndex.md)
- [Window.FindByTitle](WindowFindByTitle.md)

### Example Databases

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

This function checks for a license.

Created 1st November 2016 , last changed 3th November 2016

  
[TouchBar.AssignToApp](TouchBarAssignToApp.md) - [TouchBar.Available](TouchBarAvailable.md)

[HTML Version](TouchBarAssignToWindow.shtml)