Search code examples
swiftxcodemacosnsbutton

How do I make a macOS button become highlighted (blue)?


I've tried this:

myButton.highlight(true)

But this only turns the button into a darker blue, which is the "pressed down" state of the button.

Also, the button won't work when I press enter on my keyboard.

How can I make the button highlighted(blue) and togglable when I press enter?


Solution

  • In Interface Builder, select your button. Then in the sidebar, click on the Identity Inspector and set your button's Keyboard Equivalent to the Return key.

    identity inspector