nsbutton

Why does NSToolbarItem get disabled automatically?

对着背影说爱祢 提交于 2019-12-14 01:24:02
问题 I have a bit of an issue with buttons in the toolbar of my slideshow application for Mac. I want those buttons to be disabled when there is no active slideshow and enabled when there is an active slideshow. In order to achieve this, I set the buttons' isEnabled property to false at the start (I have tried both Interface Builder and my window's windowDidLoad ) and then in the didSet of my slideshow variable I do the following: var slideshow: Slideshow? { didSet { self.playPauseButton.isEnabled

Setting Multiline Title To NSButton In Cocoa App

不打扰是莪最后的温柔 提交于 2019-12-13 08:17:42
问题 I understand the NSButton guidelines for setting title to NSButton, No offence but the requirement should be fulfilled in my case. I want to show NSButton title in two lines. NSButton *btn = [[NSButton alloc] init]; [btn setTitle:@"multiple line text if longer title"]; the result I wanted was kind of below -: 回答1: I have fulfilled the requirement by subclassing the NSButton and then checked the title's string length to divide string accordingly to show it in two line. NSArray *arrStr = [str

How to set NSButton's keyEquivalent to NSDownArrowFunctionKey in Swift

丶灬走出姿态 提交于 2019-12-13 05:05:00
问题 How do I set an NSButton's keyEquivalent (which is a String type) to the down arrow key in Swift? NSDownArrowFunctionKey is an Int. 回答1: This page in Apple's documentation addresses this exact issue. The example they provide is written in Objective-C, the Swift equivalent is as follows: import Cocoa @NSApplicationMain class AppDelegate: NSObject, NSApplicationDelegate { @IBOutlet weak var window: NSWindow! @IBOutlet weak var button: NSButton! func applicationDidFinishLaunching(aNotification:

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

NSButton disabled title color always gray

房东的猫 提交于 2019-12-13 00:39:28
问题 I have a custom NSButton, but no matter what i do, the disabled color is always gray I tried all solutions i came across i'am setting the attributed string title with white foreground color (i looks like the color attribute is ignored for the disabled state) i did set [[self cell] setImageDimsWhenDisabled:NO]; event when the documentations states // When disabled, the image and text of an NSButtonCell are normally dimmed with gray. // Radio buttons and switches use (imageDimsWhenDisabled ==

How to make NSButton title at bottom and centered?

混江龙づ霸主 提交于 2019-12-12 17:53:10
问题 How can I make a button's title at bottom and centered programmatically? 回答1: Subclass NSButtonCell and override drawTitle:withFrame:inView:( drawTitle(_,withFrame,inView) in swift) to draw the title centered by manipulating frame parameter for example, or draw the title by yourself. Then set your button's cell class to your subclass. Or place NSTextField over your button, set constraints to anchor the bottomcenter of the button and set its text to whatever you want, and keep your buttons

NSButton RadioGroup (NSMatrix Alternative)

倖福魔咒の 提交于 2019-12-12 08:26:11
问题 I've tried a few times to set up several similar buttons, all connected to the same IBActions, and still can't seem to replicate the RadioButton Behaviour. At the moment, I have 5 Buttons, all children of one NSView.. NSView - ButtonOne - NSButton (Square Button) - ButtonTwo - NSButton (Square Button) - ButtonThree - NSButton (Square Button) - ButtonFour - NSButton (Square Button) - ButtonFive - NSButton (Square Button) They're all connected to a common IBAction, which reads as: @IBAction

NSButton on NSVisualEffectView: Wrong Background Color

最后都变了- 提交于 2019-12-12 07:37:32
问题 I have a NSVisualEffectView within a NSPopover developed for 10.10 . When subclassing the NSVisualEffectView to have hover background color effect, the borderless button color seems to be different I tried setting the backgroundColor of the button cell to clearColor or the same as I used in drawRect: in of the NSVisualEffectView , the former gives wrong color (not filled with blue) and the later still the same with wrong color. (gray box around its border). CALayer can fix this but is there a

How to remove gray border from NSButton?

十年热恋 提交于 2019-12-12 05:28:54
问题 I´m trying to make a simple colored NSButton. It seems there are two problems i don´t get solved: 1. How can I stop the button from being highlighted when clicked? I set a red background to my button: . When clicked, the color disappears: How could I keep the backgroundcolor, even when the button is clicked?. How could I remove the gray border? I tried different things: class myButton: NSButton { override func draw(_ dirtyRect: NSRect) { super.draw(dirtyRect) self.wantsLayer = true self

How to create NSButton with delayed NSMenu?

只谈情不闲聊 提交于 2019-12-12 02:09:20
问题 In Cocoa i want to create an nsbutton with delayed menu. i.e., When clicked it should call the action method and when kept in pressed state for 2 seconds it should display a nsmenu. It is similar to "Build Active Target" button present in Xcode toolbar. Regards, Dhanaraj. 回答1: It's a NSPopUpButton.. Here is how I create it in my app. NSToolbarItem* item = [[[NSToolbarItem alloc] initWithItemIdentifier:identifier] autorelease]; [item setLabel:label]; [item setPaletteLabel:label]; [item