I have one NSTextView within NSBox. I want to draw focus ring aroung NSBox whenever NSTextView got focus and remove focus ring as soon as NSTextView lost focus.
Thanks,
I have one NSTextView within NSBox. I want to draw focus ring aroung NSBox whenever NSTextView got focus and remove focus ring as soon as NSTextView lost focus.
Thanks,
Copyright © 2021 Jogjafile Inc.
To do this, create a subclass of NSTextView, and override the -becomeFirstResponder like so:
You can set up an NSNotification in the if statement above so that when that code block gets run, your view containing the NSBox can get called and subsequently draw a focus ring on the NSBox. To handle the NSTextView losing focus, you'll want to override -resignFirstResponder, like so:
Be sure to change the class in interface builder, and change your class type in your header and/or implementation files to your new subclass of NSTextView: