Reputation: 7725
I need to simulate a button press on my Cocoa button programatically and I am trying to do this on cocotron which unfortunately does not have the NSEvent method: mouseEventWithType:location:modifierFlags:timestamp:windowNumber:context:eventNumber:clickCount:pressure: implemented. Is there anyway to programatically simulate a button press without having to create an event?
Upvotes: 1
Views: 1560
Reputation: 96323
Don't forget to look in superclasses when you're looking for something. All NSControls, including all NSButtons, respond to a performClick:
message.
That said, is it really appropriate for you to simulate a button press? If you just want something done, it's generally better to directly tell the controller to do it.
Upvotes: 6