简体   繁体   中英

NSButton: setting different focus ring color

I'm trying to set the NSButton focus ring color to white. Currently, when the button has firstResponder, it shows a blue outline.

I am aware that there is the drawFocusRingMaskWithFrame:inView: to help do this, but I'm not sure how to use this to change the color to white. I haven't seen any working examples of this API in use.

Thanks.

There's no way to do this. Your app has no direct control over the color of the focus ring. It only provides the shape (effectively a mask) and AppKit uses that to draw the focus ring.

You can try to turn off the drawing of the focus ring for a particular view and then draw something intended to approximate a focus ring. However, this won't work well. The focus ring often extends beyond the frame of focused view, while the view's drawing can't.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM