Re: Icon radio buttons
Re: Icon radio buttons
- Subject: Re: Icon radio buttons
- From: Steve Christensen <email@hidden>
- Date: Wed, 24 Jan 2018 09:24:11 -0800
You could manage the button state yourself without a lot of code.
@IBOutlet var button1: NSButton // tag = 0
...
@IBOutlet var buttonN: NSButton // tag = N - 1
private var selectedPaletteButtonIndex: Int = 0
private var paletteButtons: [NSButton]
override func viewDidLoad()
{
super.viewDidLoad()
paletteButtons =
[
button1,
...
buttonN
]
paletteButtons[selectedPaletteButtonIndex].state = .on
}
@IBAction func paletteChanged(_ button: NSButton)
{
let newSelectedPaletteButtonIndex = button.tag
if selectedPaletteButtonIndex != newSelectedPaletteButtonIndex
{
paletteButtons[selectedPaletteButtonIndex].state = .off
paletteButtons[newSelectedPaletteButtonIndex].state = .on
selectedPaletteButtonIndex = newSelectedPaletteButtonIndex
}
}
> On Dec 20, 2017, at 5:04 PM, Casey McDermott <email@hidden> wrote:
>
> Is there a way to have a palette of icon buttons act like radio buttons,
> without use of the deprecated NSMatrix? The goal is something like the
> drawing tool palette in the Sketch sample app (or ancient MacDraw).
>
> In IB, it is not possible to add an image to a NSButton with style radio. It
> automatically changes to a bevel button when the image is added. Likewise,
> with style rectangle, the type can't be radio.
>
> Thanks,
>
> Casey McD
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden