I'm currently implementing the NSTouchBar api to my macOS application.
At this moment, the only touch bar I have has the main View Controller as its delegate and I can add items to it fine. The catch is, I need some of those items to appear only when a certain condition is met (a row is selected in a table).
Consider I have a boolean that indicates whether or not the button should be visible. How do I update the NSTouchBar on the fly to show/hide this button in case my boolean changes? (I don't need to observe this boolean, I could simply make the call to update in another method I already implemented)
What I did for now is the following: in touchBar(:makeItemForIdentifier)
, I have a switch for all identifiers, and under the proper case
, I either return the NSCustomTouchBarItem
with the button, or nil
if my boolean is false
.
I tried calling makeTouchBar
again after a row of the table is selected but it doesn't update the buttons' visibility, as if touchBar(:makeItemForIdentifier)
is not called again.
Thanks!