• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Icon radio buttons
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

References: 
 >Icon radio buttons (From: Casey McDermott <email@hidden>)

  • Prev by Date: Icon radio buttons
  • Next by Date: Size of compiled NIBs in Xcode 9 (10.13 SDK)
  • Previous by thread: Icon radio buttons
  • Next by thread: Re: Re: Icon radio buttons
  • Index(es):
    • Date
    • Thread