Add NSSliderTouchBarItemMBS to TouchBar?

How to add a NSSliderTouchBarItemMBS to the Touch Bar?

What have you tried?

You subclass NSSliderTouchBarItemMBS to fill in code for events.
Then make objects of that in makeItemForIdentifier to return a slider.

In action you may read current value and move a slider in your GUI to match for example.

System.DebugLog CurrentMethodName
dim t as new MyNSTouchBarMBS

t.customizationIdentifier = “”
t.principalItemIdentifier = “test”

dim DefaultItems() as string
DefaultItems.Append “test”
DefaultItems.Append “print”
DefaultItems.Append “Slider”
DefaultItems.Append NSTouchBarItemMBS.NSTouchBarItemIdentifierFixedSpaceSmall
DefaultItems.Append NSTouchBarItemMBS.NSTouchBarItemIdentifierOtherItemsProxy

t.setDefaultItemIdentifiers DefaultItems

// test item must be there, print can be removed
t.setCustomizationRequiredItemIdentifiers array(“test”)
t.setCustomizationAllowedItemIdentifiers array(“print”)
t.setCustomizationAllowedItemIdentifiers array(“Slider”)

self.myTouchBar = t

var s as new MyNSSliderMBS(“Slider”)
var m as new MyNSCustomTouchBarItemMBS(identifier)

s.minValue = 0
s.maxValue = 200
m.Slider = s
items.Append m
Return m

But no slider is visible.
MyNSSliderMBS is a subclass of NSSliderTouchBarItemMBS
Example project file

Please no NSCustomTouchBarItemMBS one, but a slider item with NSSliderTouchBarItemMBS:

[code]Dim m As New MyNSSliderTouchBarItemMBS(identifier)

m.value = 0
m.minValue = 0
m.maxValue = 200
m.label = “Slider”
items.Append m
Return m[/code]

And MyNSSliderTouchBarItemMBS is a subclass of NSSliderTouchBarItemMBS to catch Action event.

NSSliderTouchBarItemMBS.value is not supporting Retina display and ScalingFactor. When I set value and maxValue of a NSSliderTouchBarItemMBS.value to the same value as a Slider.value on window1 and I move the slider on the Touch Bar, the window1.Slider has a value of 100% but the Touchbar.Slider is only at 50%.

wDetials.ScrollBar1.Value = wDetails.ccDetails1.Height

NSSliderTouchBarItemMBS => Action Event
wDetails.ScrollBar1.Value = me.value

MyDetailsNSTouchBarMBS => makeItemForIdentifier
var As New MyNSSliderTouchBarItemMBS(identifier)

m.value = wDetails.ScrollBar1.Value
m.minValue = 0
m.maxValue = wDetails.ccDetails1.Height/2
m.label = “Scroll”
items.Append m
Return m

NSSliderTouchBarItemMBS certainly supports Retina.

Not sure where the *2 or /2 is in your code to break this.

If I use “m.maxValue = wDetails.ccDetails1.Height”, then window1.Slider has a value of 100% but the Touchbar.Slider is only at 50%
If I use m.maxValue = wDetails.ccDetails1.Height/2, both sliders has the same value.

why set the maximum value to the height of some container?

doesn’t make sense to me at all.

maximum should be something like 100 if it is percent setting.

Okay I will change it.