Einhugur macOS Bridge plugin. |

# NSTouchBar.RegisterForWindow Method

Registers Touch-bar for at window level. (This variation of the method takes new style Xojo DesktopWindow)

shared RegisterForWindow(
windowInstance as DesktopWindow,
makeTouchBarHandler as MakeTouchBarDelegate) as EinhugurMacOSBridge.NSTouchBarResponder

#### Parameters

windowInstance
  Instance of a Window to add Touch-bar to.
makeTouchBarHandler
  Function you pass into this delegate that will handle creating the Touch Bar each time the macOS went to generate the touch-bar. This parameter may not be nil.
  The signature of this function should be SomeFunctionName() as EinhugurMacOSBridge.NSTouchBar.

#### Returns

EinhugurMacOSBridge.NSTouchBarResponder
  Token that you need to store in property on your Window class.

#### Remarks

This variation of the method will only show up for Xojo 2021r3 or later.
Your application can have touch-bar for the application and for each window.
Normal place to call this one would be in the Window.Open event.
The NSTouchBarResponder token returned by this method you need to store in property on your Window class. When the token is either set to nil or goes out of scope then the Touch Bar will be taken down.
Example use:
Property in your Window class:

Private Property responder as EinhugurMacOSBridge.NSTouchBarResponder
In Window.Opening event:
Sub Open() Handles Open
responder = EinhugurMacOSBridge.NSTouchBar.RegisterForWindow(self, addressof CreateTouchBar)
End Sub
In your Window class a method to respond to the delegate to setup the Touch Bar:
Private Function CreateTouchBar() as EinhugurMacOSBridge.NSTouchBar
using EinhugurMacOSBridge
// Code here to create and return the Touch Bar
End Function

#### See Also

NSTouchBar Class