Click NSPushButton Software with Animation

I just ran into a problem that I already know from other programming languages ​​/ frameworks .... Whenever a user presses a certain button on the keyboard, he starts the same action as when a certain button is pressed in the graphical interface. (Some guys call these "shortcuts", D)

To give the user optical feedback, I would like to sort the β€œclick” button programmatically, rather than calling the same functions that are called when the button is clicked.

If I set the button as the key equivalent in IB, it looks the way I want it. It is not possible to do this here, since the shortcut should be included only if the desired text fields have focus.

Could not find a method in NSButton or similar that sounded right. I'm sure you guys can give me some direction!

Best and thanks in advance

+4
source share
1 answer

You can simply send performClick: to the button. He will highlight himself, send his action to his goal, and then highlight.

 [self.someButton performClick:self]; 

If you really want to simply select and highlight the button manually, you can use the highlight: method.

 [self.someButton highlight:YES]; // button appears pressed [self.someButton highlight:NO]; // button appears unpressed 
+21
source

Source: https://habr.com/ru/post/1390550/


All Articles