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
6
votes
5 answers

how to set background color of NSButton OSX

I want to set the background color of NSButton.There was nothing in the attribute inspector so i was wondering if there was any way to do it programmatically?
Zeist
  • 635
  • 1
  • 7
  • 17
6
votes
2 answers

How to force the cursor to be an "arrowCursor" when it hovers a NSButton that is inside a NSTextView?

Okay, here is the problem: I have a NSTextView and I add my custom NSButton using: [_textView addSubview:button]; Then, inside my NSButton subclass, I have (along with the NSTrackingArea stuff): - (void)mouseEntered:(NSEvent *)event{ …
Pedro Vieira
  • 3,330
  • 3
  • 41
  • 76
6
votes
4 answers

Checking if NSButton is down on drawRect

I would like to check if my custom NSButton is currently in a pressed state (the user is clicking down on it) in my custom drawRect method. Something like this: - (void)drawRect:(NSRect)dirtyRect{ if ([self buttonIsInPressedState]) { …
Holger Sindbaek
  • 2,278
  • 6
  • 41
  • 68
5
votes
2 answers

remove blue shadow of NSButton

Always (programmatically or via IB) i get this blue shadow on the first set button: I want to get rid of it.. how?
Diego Torres
  • 5,308
  • 5
  • 25
  • 29
5
votes
3 answers

NSButton subclass that responds to right clicks

I have an NSButton subclass that I would like to make work with right mouse button clicks. Just overloading -rightMouseDown: won't cut it, as I would like the same kind of behaviour as for regular clicks (e.g. the button is pushed down, the user can…
Gustav Larsson
  • 8,199
  • 3
  • 31
  • 51
5
votes
2 answers

NSButton does not call its action

I am having a little trouble with NSButton's action. I programmatically create a button ... let continueButton = NSButton(title: "Continue", target: self, action: #selector(self.continueButtonClicked)) ... to call this function: @objc func…
Jan Kaiser
  • 830
  • 1
  • 8
  • 22
5
votes
1 answer

NSButton's images lose transparency on selection

I have edited some NSButtons in my Mac OS X application and set a custom image to them. The images are in png format with transparency. When I select a button, the background of the image goes white. Does anyone know of a way to fix this?
Ricky
  • 3,101
  • 1
  • 25
  • 33
5
votes
1 answer

Checking state of NSButton Checkbox on Xcode for macOS apps swift 3

I have an NSButton Checkbox on Xcode using Swift 3 for making macOS applications. I'm trying to check the state (whether its on or off). Some options I have found, such as : if ([Switch1 state] == NSOnState) { //CODE} When I do this, it tells me…
Hussein Esmail
  • 353
  • 5
  • 21
5
votes
1 answer

NSButtonCell as Checkbox in a NSTableVIew don't get selected

I have a NSTableVIew for multi-selection purposes with two columns, the first one with a NSButtonCell as checkbox and the other one as a title. The idea is to check the items to be added afterwords to an array. The problem is that the checkboxes…
Omer
  • 5,470
  • 8
  • 39
  • 64
5
votes
3 answers

NSButton with variable size width, rounded corners

What is the best way to create an NSButton with a custom background image, that is able to have variable width, without making the corner bezel look stretched? I know there are convenience methods to do this with UIButton:…
BadPirate
  • 25,802
  • 10
  • 92
  • 123
5
votes
1 answer

NSButton corner radius and NSPopover

I'm using an NSPopover and I'm putting a NSViewController inside to be displayed as a custom view from a NSStatusItem. Most of the view controller displays correctly except for the NSButton that have a corner radius on them. There is some extra…
cmakthat
  • 201
  • 4
  • 7
5
votes
1 answer

Opt-out borderless NSButton from NSVisualEffectView vibrancy

I have a NSVisualEffectView with vibrancy containing text fields (NSTextField or NSComboBox) and borderless buttons. The buttons are positioned over the text fields and I want to disable the vibrancy effect on the borderless buttons since they're…
beeb
  • 1,187
  • 11
  • 32
5
votes
2 answers

Making a Cocoa Button look like is pressed, programmatically

I have some key events, that correspond to buttons also. What property/method to I have to set/call for a button to look depressed (change state?) for say half a second?
5
votes
1 answer

Radio buttons without using NSMatrix

In the AppKit release notes for OS X 10.10, Apple wrote: Use of NSMatrix is informally deprecated. We expect to add the formal deprecation macros in a subsequent release, but its use is discouraged in the mean time. The primary use of NSMatrix is…
Dejal
  • 813
  • 6
  • 18
5
votes
0 answers

Image size of image in an NSButton

I'm trying to add an image to an NSButton. No matter what dimensions I make the image it is being cropped (see the button to the left in the screenshot). This is a simple NSRoundedBezelStyle NSButton. In this case my image is 15x15 and the button…
RobertJoseph
  • 7,968
  • 12
  • 68
  • 113