nstoolbaritem

Show NSPopover from NSToolbarItem Button

余生颓废 提交于 2020-05-10 09:46:04
问题 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 NSToolbarItem ? [toolbarbutton view] always returns nil. 回答1: The answer appears to be in the video for the 2011 WWDC Session 113, "Full Screen and Aqua Changes." Basically, put an NSButton inside the NSToolbaritem and use the view of that. A blog post is here:

Show NSPopover from NSToolbarItem Button

与世无争的帅哥 提交于 2020-05-10 09:45:12
问题 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 NSToolbarItem ? [toolbarbutton view] always returns nil. 回答1: The answer appears to be in the video for the 2011 WWDC Session 113, "Full Screen and Aqua Changes." Basically, put an NSButton inside the NSToolbaritem and use the view of that. A blog post is here:

Automatic Styling/Tinting of NSToolbarItem

情到浓时终转凉″ 提交于 2020-01-01 19:05:44
问题 Is there a way to tell OS X to automatically style/tint a NSToolbarItem ? I've added an "Image Toolbar Item" via IB/Xcode and set the icon to a black PDF as described in the documentation. However, my result does not resemble that of, for instance, the App Store: I'm looking for something akin to what the TabBar in iOS does by default. I'm new to OS X development... So any guidance would be appriciated! 回答1: Images need to be made template'd in order to get the correct styling (such as the

Align NSToolbarItems with NSSplitView columns

久未见 提交于 2019-12-31 00:50:11
问题 Finder and Notes have a peculiar behaviour that I am seeking to reproduce. The ‘flexible space’ in the NSToolbar seems to take the dimensions of the split view into account. For instance, the first group of buttons aligns on the left side with the right side of the sidebar. The second group of icons aligns with the right side of the first column. When I widen the sidebar, the toolbar items move along with it. Is it possible to reproduce this? Solution With the solution provided by

NSToolbarItem validation in relevant controller

折月煮酒 提交于 2019-12-22 05:42:07
问题 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 NSSplitViewController, somewhere in the view hierarchy of the window’s content view. I want to validate both items, but have that specific split-view controller take care of the validation, because it relies on some conditions local to that controller. I

Toggle NSToolbarItem between Black and Blue

半世苍凉 提交于 2019-12-21 09:27:08
问题 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, but I haven't found that to be the case. I set it to a template image, and that causes it properly render the dark gray gradient, but it doesn't render in blue when toggled. I uploaded a very simple example of what I've done, here. If someone could

NSButton in NSToolbar item: click issue

≡放荡痞女 提交于 2019-12-13 04:30:23
问题 I want to use a NSButton configured to show only an image in my NSToolbarItem . The item is created in IB and the code to add the button to it is: NSButton *button = [[NSButton alloc]init]; [button setImage:[NSImage imageNamed:@"StarEmpty"]]; [button setAlternateImage:[NSImage imageNamed:@"StarFull"]]; [button setImagePosition:NSImageOnly]; [button setBordered:NO]; [self.toolbarItem setView:button]; The problem is that when i click on the image instead of the alternate image a lighter

NSToolbarFlexibleSpaceItem is constraint to NSSplitViewItem in Swift

余生长醉 提交于 2019-12-12 16:08:33
问题 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 app and customize the toolbar. The first flexible space is detected and moved along with first split view item. The second flexible space is detected and moved along with the second split item. The rest will be just normal flexible spaces. If there

How to make NSToolbar label move with it's Icon when both of them are visible

时光怂恿深爱的人放手 提交于 2019-12-11 21:21:11
问题 My app has an NSToolbar with a horizontal NSSplitView below it. An NSSegmentedControl in the toolbar moves with the splitview's divider, just like the one in OS X's Finder. NSLayoutGuide was used to align the two "views" from different storyboard "scenes". I shared this approach in this related question. However, I don't know how to move the label with the icon. I've set the minSize and maxSize , but the label is fixed. In the first screenshot below, the "View Mode" label is not right below

NSToolbarItem with Segmented Control - Images Not Rendering Correctly

不打扰是莪最后的温柔 提交于 2019-12-11 07:03:14
问题 I'm trying to emulate Xcode's toolbar controls to show/hide the Navigator and Inspector: ...but without the bottom pane (only left and right: two segments) I screen-captured the icons from Xcode's UI and traced them in an image editing application. The resources for the left pane are: @1x: (20x20 @72 dpi) @2x: (40x40 @72 dpi, although using 20x20 @144 dpi seems to make no difference) The right-pane counterparts are identical, but flipped horizontally. All rhe resources are stored in the asset