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
34
votes
13 answers

NSButton how to color the text

on OSX I have an NSButton with a pretty dark image and unfortunately it is not possible to change the color using the attributes inspector. See picture the big black button, the text is Go. Any clues for a possibility to change the text color? I…
Ronald Hofmann
  • 1,390
  • 2
  • 15
  • 26
31
votes
3 answers

Borderless NSButton turns gray when clicked

I am making a little application with three NSButtons with an image set. These buttons have no border nor background. However, when I click a button it turns into a gray rectangle. How can I fix this? Thanks.
user142019
27
votes
7 answers

Simple mouseover effect on NSButton

I am creating a custom NSButtonCell for a custom rendering. Now, I want to have different aspect depending if the mouse is over the button or not. How can I get this information? Thanks and regards,
AP.
  • 5,205
  • 7
  • 50
  • 94
18
votes
5 answers

Cocoa: change cursor when it's over an NSButton

How can I change the cursor when it's over an NSButton?
Matt S.
  • 13,305
  • 15
  • 73
  • 129
16
votes
1 answer

creating simple action if NSButton is pressed in swift

I am in the process of learning swift. I would like to know how to call a function programmatically if a button is pressed. I tried this, but the function is executed directly when the program launches, not when I press the button. Can you please…
iznogoud
  • 173
  • 1
  • 1
  • 4
14
votes
2 answers

Automatically resize an NSButton to fit programmatically changed text (Xcode)

I have an NSButton (Push Button) with some temporary title text built in Interface Builder / Xcode. Elsewhere, the title text inside the button is changed programmatically to a string of unknown length (actually, many times to many different…
Ryan
  • 474
  • 1
  • 3
  • 12
14
votes
3 answers

how to code NSButton to look just like image

Using code (not the Interface builder) I need to create an NSButton that looks like an image. Specifically I want to use NSImageNameStopProgressFreestandingTemplate and I need it not to look like button but to look like the image. This means: 1. No…
OZG
  • 509
  • 7
  • 19
13
votes
4 answers

Disable/Enable NSButton if NSTextfield is empty or not

I´m newbie with cocoa. I have a button and a textField in my app. I want the button disabled when the textfield is empty and enabled when the user type something. Any point to start? Any "magic" binding in Interface Builder? Thanks [EDITED] I´ve…
Azpiri
  • 774
  • 1
  • 9
  • 20
13
votes
4 answers

Cocoa osx NSButton show text when mouse over

In my application for Mac I want to show some info text when the users moves the mouse pointer over a button. Something like this: How can I achieve this correctly? Thanks in advance.
user3065901
  • 4,678
  • 11
  • 30
  • 52
13
votes
4 answers

NSButton mouseDown mouseUp behaving differently on enabled

If the NSButton is not enabled, the mouseDown: and mouseUp: behave as expected (so when the mouse is pushed down, the mouseDown: is called, and when it is released, the mouseUp: is called) However, if the NSButton IS enabled, than the mouseUp:…
Peter Lapisu
  • 19,915
  • 16
  • 123
  • 179
13
votes
2 answers

Unable to set height of NSButton

I have some NSButtons of style Round Textured inserted into an NSToolbar. I have created some custom images for the buttons and would like to make them vertically bigger, however the height field for the button is greyed out. Anyone got any ideas…
Gareth Jeanne
  • 1,410
  • 2
  • 19
  • 35
12
votes
4 answers

NSButton with delayed NSMenu - Objective-C/Cocoa

I want to create an NSButton that sends an action when it is clicked, but when it is pressed for 1 or two seconds it show a NSMenu. Exactly the same as this question here, but since that answer doesn't solve my problem, I decided to ask again. As an…
Alex
  • 5,009
  • 3
  • 39
  • 73
11
votes
4 answers

Cocoa/OSX - NSWindow standardWindowButton behaving strangely once copied and added again

In my app I change the position of the standardWindowButtons close / miniturize / expand like so: //Create the buttons NSButton *minitButton = [NSWindow standardWindowButton:NSWindowMiniaturizeButton forStyleMask:window.styleMask]; NSButton…
Zigglzworth
  • 6,645
  • 9
  • 68
  • 107
11
votes
1 answer

NSButtonCell highlighting remains on keypress in Mojave

I have a class derived from NSButtonCell where I draw bezel: override func drawBezel(withFrame frame: NSRect, in controlView: NSView) { let path = NSBezierPath(bound: frame.insetBy(dx: CGFloat(config.buttonInset), dy:…
Pablo
  • 28,133
  • 34
  • 125
  • 215
10
votes
4 answers

Objective-c: NSButton setAction not working

I'm making a couple of buttons programmatically and trying to set an action to each but I can't seem to get it to work. In my AppController.h I have this code: ... IBOutlet NSButton* btnZoomIn; IBOutlet NSButton* btnZoomOut; ... and - (IBAction)…
PruitIgoe
  • 6,166
  • 16
  • 70
  • 137
1
2 3
35 36