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
4
votes
2 answers

NSView drawRect interfering with subviews?

I have an nsview and i use draw rect to draw an image for background. It also has 3 subviews nsbuttons. The problem is, whenever the mouse is down on a button, the other buttons disappear. But when I remove the draw rect method, this doesn't happen.…
user635064
  • 6,219
  • 12
  • 54
  • 100
4
votes
1 answer

NSButton Inside NSTextField

I'm trying to create a NSTextField with a button on its right side (similar to a NSSearchView), but I can't figure out how to have the NSTextField's text scroll without going under the NSButton. Here is my code thus far: rightButton = [[NSButton…
individualtermite
  • 3,615
  • 16
  • 49
  • 78
4
votes
3 answers

Disable NSButton without grayed image

I want to disable the user interaction of NSButton. The only possible option seems to be setting isEnabled to false: button.isEnabled = false ...but the problem is that it's giving a white shade to the image of my button. Is there any way to get…
bisma
  • 795
  • 6
  • 26
4
votes
1 answer

Why does NSToolbarItem get disabled automatically?

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…
Jan Kaiser
  • 830
  • 1
  • 8
  • 22
4
votes
0 answers

Modifying the look of an NSButton with a CALayer works differently in macOS 10.12 and 10.10

I am trying to change the look of an NSButton in my app. The button is "Square" and "Momentary Push In". The code is: let layer = CALayer() toggleTimespanButton.wantsLayer = true toggleTimespanButton.layerContentsRedrawPolicy =…
hkdalex
  • 717
  • 7
  • 13
4
votes
2 answers

Custom NSButton drawing messes up text rendering

I'm subclassing NSButton / NSButtonCell and everything works fine, but at least in Retina drawing as soon as I implement any of the drawing functions in either NSButton or NSButtonCell, the text rendering changes no matter whether I do some custom…
Frank R.
  • 2,328
  • 1
  • 24
  • 44
4
votes
0 answers

Xcode interface builder resets NSToolbarItem sizes on its own, then complains about it

Ever since updating to Xcode 8 and Sierra, I get the following error message in the console when running the app: NSToolbarItem (NSToolbarItem: 0x608000121360) had to adjust the size of NSButton: 0x608000140160 from {35, 25} to the expected size of…
beeb
  • 1,187
  • 11
  • 32
4
votes
4 answers

How to handle assertion failure on NSButton lockFocus when using modalWindow on quit?

a button's IBAction in windowA calls runModalForWindow:windowB. windowB becomes key and modal. windowB has a popUpWindowDatePicker which calls stopModal upon display, and then popUpWindowDatePicker becomes key, and windowB resigns key and is not…
lulu
  • 669
  • 10
  • 26
4
votes
2 answers

Key Value Observing and NSButton state

I'm trying to observe checkbox status and make appropriate changes in the app when checkbox status changes. In a window manager that manages the window with checkbox I have following observer setup: - (void)awakeFromNib { [myCheckBox…
Eimantas
  • 48,927
  • 17
  • 132
  • 168
4
votes
1 answer

How to set focus to an NSButton?

I'm writing a small menubar application for OS X Yosemite. When clicking on the menubar icon, a popover appears with a number of recessed buttons. Like so: As you can see, the "d4" button is focused, even though the d20 is selected by default.…
camden
  • 1,908
  • 19
  • 18
4
votes
2 answers

How to trigger button action on leftMouseDown in Swift, Mac OSX, Cocoa

I want to trigger a button on left mouse down in my mac osx app using swift. This is the way to do it in Objective-C [myButton sendActionOn:NSLeftMouseDownMask]; I can't figure out how to do it in Swift. Can anybody help me out with my…
stefOCDP
  • 803
  • 2
  • 12
  • 20
4
votes
1 answer

Add NSClickGestureRecognizer to NSButton programmatically swift

I have multiple NSButtons generated with this code: var height = 0 var width = 0 var ar : Array = [] var storage = NSUserDefaults.standardUserDefaults() height = storage.integerForKey("mwHeight") width =…
user4226616
4
votes
4 answers

NSButton state not changing

The following code works perfect in my sandbox: @IBAction func filterClicked(sender: NSButton) { println(sender.state) if let clickEvent = NSApp.currentEvent! { if Int(clickEvent.modifierFlags.rawValue) &…
qwerty_so
  • 35,448
  • 8
  • 62
  • 86
4
votes
2 answers

Create square NSButton programmatically swift

There's my code: var newBut = NSButton(frame: NSRect(x: 150, y: 200, width: 30, height: 30)) newBut.title = "press me!" self.view.addSubview(newBut) But it creates the button that differs from square button. It's darker and has smh like a shadow.…
user4226616
4
votes
0 answers

NSCell KVO monitoring highlighted

I want to monitor the buttons cell highlighted state, but the callback gets never call, although the highlight changes monitoring the keyPath "state" works, but why doesn't monitoring highlighted? - (void)awakeFromNib { [super awakeFromNib]; …
Peter Lapisu
  • 19,915
  • 16
  • 123
  • 179