Questions tagged [nsbutton]

The NSButton class is a subclass of NSControl that intercepts mouse-down events and sends an action message to a target object when it’s clicked or pressed.

535 questions
8
votes
1 answer

NSButton Event Handling in Xcode 6 with Swift

I want to set the action and target for an NSButton in swift. In previous versions of Xcode, there were setAction and setTarget methods, but those aren't included in the Cocoa library anymore (or they aren't as far as I can tell). What is the…
Kyle Somers
  • 614
  • 1
  • 8
  • 21
8
votes
2 answers

Issue with a checkBox in a viewbased NSTableView

I have an NSDictionary that holds all the data: One title (not important for this question) One link (not important for this question) One array of NSDictionary containing again 1 title and 1 link I'm displaying this data in a view based table…
ItsASecret
  • 2,589
  • 3
  • 19
  • 32
7
votes
1 answer

NSButton without "click highlighting"

I've got an NSButton with an image (and no text), over a blueish background. The Style is "Square", type is "Momentary Push In", not bordered etc. When I click the button, there is a light rect around it, which is highlighted for a second. How do I…
tamasgal
  • 24,826
  • 18
  • 96
  • 135
7
votes
3 answers

How to setKeyEquivalent to Enter/Return key on NSButton?

I've tried [myButton setKeyEquivalent:@"\n"] but that didn't work. I feel like there should be some predefined constant for it that I'm just missing. Thanks.
Randall
  • 14,691
  • 7
  • 40
  • 60
7
votes
1 answer

Remove Background From NSButton

Hey so i have a table view embeded in a visual effect view, in one of the rows i have a save button and the save button every time i click the cell gets this funky background color around it. Iv tried saveButton.wantsLayer =…
Eli
  • 668
  • 2
  • 13
  • 37
7
votes
4 answers

Swift Mac OSX NSButton title color

I would like to know how to change title color to a NSButton in swift, I've seen lots of examples in objective-c but I think in swift the implementation is different, can anyone provide me an example?
PhiceDev
  • 507
  • 2
  • 6
  • 22
7
votes
3 answers

Change NSButton's background color on highlight

I have an NSButton which I want to have a different background color when it's highlighted than when it's not (transparent on not highlighted, if that makes any difference). At present, I have the following code [view setWantsLayer:YES]; NSButton*…
cobbal
  • 69,903
  • 20
  • 143
  • 156
7
votes
8 answers

How to check if Option key is down when user clicks a NSButton

I have a few checkboxes along with textfields on a NSPanel that opens to get user parameters. As an option, I'd like the user to be able to set/unset all the checkboxes on the panel by holding the option key when they press any of the…
vcirilli
  • 321
  • 3
  • 13
7
votes
2 answers

Programmatically create and position an NSButton in a macOS app?

How do I programmatically create and position a button in a macOS Cocoa application?
Matt Payne
  • 173
  • 1
  • 1
  • 12
6
votes
2 answers

Disclosure button displaying a menu

Please give me an advice how to implement this kind of disclosure button as on my screenshot - a disclosure "arrow down" button displaying a menu on click: I've tried two approaches, using NSPopupButton and NSButton with disclosure style and manual…
iHunter
  • 6,205
  • 3
  • 38
  • 56
6
votes
2 answers

Make NSButton open fonts panel

I was wondering how to go about making a button open up the fonts panel in Mac OS X using Cocoa, I have an NSTextView in my application and want the fonts dialogue to display when the user clicks the button. Thanks in advance!
user437038
6
votes
0 answers

NSButton in Catalina has no selected state

I have an NSButton set as a checkbox with the following code on Catalina (Mojave is fine): let checkbox = NSButton(frame: NSRect(x: 0, y: 0, width: 200, height: 32)) checkbox.setButtonType(.switch) checkbox.title = "Sustain" checkbox.state =…
Chris
  • 2,739
  • 4
  • 29
  • 57
6
votes
3 answers

Is it possible to make a circular NSButton?

I am trying to create a custom shape NSButton. In particular I am trying to make a round button, using a custom image. I've found a tutorial on the creation of custom UIButton and tried to adapt it to NSButton. But there's a huge problem.…
Anna-Lischen
  • 856
  • 1
  • 16
  • 35
6
votes
2 answers

NSButton on NSVisualEffectView: Wrong Background Color

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…
Cai
  • 3,609
  • 2
  • 19
  • 39
6
votes
4 answers

How can I set the text color of an NSButton via Interface Builder?

There are several questions about how to set the text color programmatically. That's all fine, but there's got to be a way to do it via Interface Builder also. The "Show Fonts" box works for changing the size of the button text, but Xcode ignores…
Troy
  • 21,172
  • 20
  • 74
  • 103
1 2
3
35 36