I am currently implementing NSTouchBar api for my macOS application.
At this point, the only touchpad I have on it has a main view controller as its delegate, and I can add elements to it. The trick, I need some of these elements to be displayed only when a certain condition is met (a row is selected in the table).
I have a boolean value indicating whether the button should be visible. How to update NSTouchBar on the fly to show / hide this button if my logical changes? (I donβt need to observe this logical one, I could just make a call to update in another method that I already implemented)
What I did now is this: in touchBar(:makeItemForIdentifier) I have a switch for all identifiers, and under the correct case I either return NSCustomTouchBarItem with a button, or nil if my boolean is false .
I tried calling makeTouchBar again after selecting a table row, but it does not update the visibility of the buttons, as if touchBar(:makeItemForIdentifier) not called again.
Thanks!
source share