Search code examples
cocoamacosnsbutton

How do I stop my NSbutton from being selected when the app starts by default?


I created a button, and a have a little problem: When the my app launches, the button is selected. How do I disable this selection?

Example:

A window with two buttons. The first (left) has a blue glow around it, and the second (right) does not.


Solution

  • Caveat: This answer is incomplete: It just hides the focus ring (without preventing the selection). There's little benefit in this solution.

    Set your button's focus ring type to none:

    [myButton setFocusRingType:NSFocusRingTypeNone];
    

    You can also set this option in the XIB.