Questions tagged [nstoolbaritem]

NSToolbarItem refers to the class in the graphical user interface toolkit Appkit framework that is an item in a window's toolbar, and which inherits from NSObject. Use this tag for questions related to such a class.

NSToolbarItem refers to the class in the graphical user interface toolkit Appkit framework that is an item in a window's toolbar, and which inherits from NSObject. Use this tag for questions related to such a class.

96 questions
14
votes
2 answers

Adding a custom view to toolbar

I'm struggling with Cocoa for 2 hours now without success. I want to add a custom view to the toolbar. So, I added a NSToolbar to the window (with IB), and added my view (which works perfectly). IB automatically created a NSToolbarItem. I followed…
user531461
13
votes
4 answers

how to enable/disable NSToolbarItem

I have a project that needs to disable/enable some NSToolbarItems depends on different options. I checked and found no parameter for this. Is there a way to enable/disable a given NSToolbarItem?
monsabre
  • 2,099
  • 3
  • 29
  • 48
13
votes
6 answers

Is it possible to draw in the label area of NSToolbar?

I have a NSToolbarItem that uses a view similar to the Xcode status view. It currently has no label, but I can't figure out a way to draw into the area where the item label would normally be drawn. I would like the view to extend into that area just…
willbur1984
  • 1,418
  • 1
  • 12
  • 21
12
votes
1 answer

How to programmatically add new NSToolbarItem to existing toolbar?

I'm looking for a method called addNewItem:(NSToolbarItem *)item or something like this that lets me add a programmatically created item to my toolbar, but I haven't found any. I would like to add an item that shows a popover when the user clicks on…
Nickkk
  • 2,261
  • 1
  • 25
  • 34
12
votes
1 answer

Big Sur Toolbar Items in the Sidebar

In Big Sur, Xcode and Calendar have toolbar items that stay over the sidebar when open but remain visible on the left side when the sidebar's collapsed. Sidebar open: Sidebar collapsed: In "Adopt the New Look of macOS" at 13:55, John says "items…
smr
  • 890
  • 7
  • 25
11
votes
5 answers

Show NSPopover from NSToolbarItem Button

I want to show an NSPopover from an NSToolbarItem button in my toolbar. (i.e. positioned below the button). Ideally, I want to pass the NSView of the button to the popover to position it. My question is, how do I get the NSView of the…
Stuart Tevendale
  • 614
  • 6
  • 19
10
votes
2 answers

How to use General and Downloads icon seen in Xcode's Preferences Panel?

I have been creating a preferences panel that would pop up when an user taps ⌘+, in my Cocoa app, and I like to use the same General and Downloads icons that are used in Xcode. However, as far as I know, when I moved Image Toolbar Item from Object…
Blaszard
  • 30,954
  • 51
  • 153
  • 233
9
votes
5 answers

NSToolbarItem: "Make sure this toolbar item has a valid frame/min/max size"?

Since upgrading to Mac OS Sierra and the new XCode version I get the following error every time I launch my application for every one of the NSToolbarItems: Example 1: 2016-09-29 12:46:58.659879 AppTest[] NSToolbarItem () had to…
MMV
  • 297
  • 2
  • 9
9
votes
1 answer

NSButton in NSToolbarItem (setView) when clicked in "Text only" forces mode to "Icon and Label"

I am trying to recreate the nice textured buttons like Finder, Safari and Transmission have in their toolbar. First I started by just dragging in a "Texture button" in the IB and such. All works well except for when a user sets the toolbar to "Text…
Ger Teunis
  • 945
  • 1
  • 14
  • 30
8
votes
2 answers

Backwards compatibility of new NSSearchToolbarItem

With macOS 11 Apple has introduced a new NSToolbarItem called NSSearchToolbarItem that automatically resizes to accommodate typing when the focus switches to the toolbar item. Here Apple says this is backwards compatible with older versions of…
Daniel
  • 1,473
  • 3
  • 33
  • 63
8
votes
1 answer

How to create consistent toolbar buttons with icons

Desired look I wish to make a toolbar for my app that will contain some simple buttons, each with a single monochromatic icon. Here is an example of some toolbar buttons similar to I'm trying to achieve, from Mail's compose window: Notice these…
Alexander
  • 59,041
  • 12
  • 98
  • 151
8
votes
1 answer

NSToolbarItem validation in relevant controller

I have an NSToolbarItem with an NSButton as its view and an NSMenuItem in the main menu. Both have the same action, which is sent to the first responder, not to a particular target. That method is ultimately implemented in a subclass of…
Eitot
  • 186
  • 1
  • 11
8
votes
1 answer

Toggle NSToolbarItem between Black and Blue

I'd like to make an NSToolbarItem with a custom image which toggles between Black and Blue, like the icons at the top right of Xcode 5's main window. Peter Hosey suggested in this answer that it was as simple as setting the image to be a template,…
ArtOfWarfare
  • 20,617
  • 19
  • 137
  • 193
7
votes
2 answers

How can I hide an NSToolbarItem using code?

I have a toolbar with various options and some options should not be visible in some cases. I have already figured out a way to disable them in my application, using this callback: - (BOOL) validateToolbarItem: (NSToolbarItem *) toolbarItem But I…
Maurício Linhares
  • 39,901
  • 14
  • 121
  • 158
7
votes
1 answer

NSToolbarFlexibleSpaceItem is constraint to NSSplitViewItem in Swift

Almost all macOS official apps have this toolbar's feature which the NSToolbarItem flexible space is constraint to NSSplitViewItem view. I first thought maybe there are 3 different sections on NSToolbar. But it just ONE toolbar. You can open Notes…
1
2 3 4 5 6 7