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?
views:
68answers:
1
+1
Q:
Looking for a cocoa method to simulate a button press that does not have an Event as a paramter
+2
A:
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.
Peter Hosey
2009-12-22 02:01:37