0

I have Cocoa application, with a code, partially hidden in a framework. I need to press NSButton programmatically.

When I use [myNSButton performClick:self], it behave differently, that when I press button physically. So I decide to find method, that linked to that NSButton. Looks like trick with [UIButton allTargets] is working only for iOS, but not for NSButton on macOS. Do you have ideas, how to find method, that linked to NSButton ?

Ol Sen
  • 3,163
  • 2
  • 21
  • 30
Alex
  • 36
  • 4
  • 2
    What's `button.action`? Also, `performClick:` is calling on a simple click, but there is `button.sendAction(on:)` https://developer.apple.com/documentation/appkit/nscontrol/1428972-sendaction you can test the various events to see which one is causing your behavior. – Larme Jul 23 '20 at 08:02
  • How is the button behaving differently? – Willeke Jul 23 '20 at 08:51
  • I found, that it was my mistake, I got id of wrong NSButton. Now performClick behave the same as physical press. But still don't find, how to find method, linked to NSButton. Any lldb command/tricks ? – Alex Jul 24 '20 at 05:26
  • 1
    @Larme already gave you a pointer - `NSButton` is a subclass of `NSControl` which contains [`action`](https://developer.apple.com/documentation/appkit/nscontrol/1428956-action?language=objc) & [`target`](https://developer.apple.com/documentation/appkit/nscontrol/1428885-target?language=objc) properties. If the `target` property is `nil` then the application follows the responder chain looking for an object that can respond to the message. – zrzka Jul 24 '20 at 11:52
  • yes this is what I need! 'po (SEL)[myNSButton action]' gives me needed selector! – Alex Jul 24 '20 at 18:48

0 Answers0