cocoanstoolbarnstoolbaritem

How do you disable the overflow menu of an NSToolbar?


I've created an NSToolbar that has a few items in Interface Builder (and set their visibility priority). When I resize the window, items are removed according to their priority as expected, however an overflow button appears with an empty menu. How can I stop this from happening?

Example


Solution

  • Each NSToolbarItem has a menuFormRepresentation property that can be set to nil to stop it from appearing in this menu. So, do this on all the items in the toolbar to stop the button from appearing:

    toolbar?.items.forEach({ (item) in
        item.menuFormRepresentation = nil
    })