Can someone show an example on how to create an NSEvent that simulates pressing return?
A:
You should take a look at the NSEvent Class Reference, and more specifically, -keyEventWithType:location:modifierFlags:timestamp:windowNumber:context:characters:charactersIgnoringModifiers:isARepeat:keyCode:
.
From there, it shouldn't be difficult. Construct all the necessary components, and send the event using NSApplication
's -sendEvent:
method.
itaiferber
2010-10-03 23:36:39
can you show an example?
Elijah W.
2010-10-04 19:55:51
You shouldn't really need an example (it's easy enough to write as it is), but here's one to look at: http://pastie.org/1199967. It assumes a lot of information that you can/should change yourself. It depends on what you are using the key press for, and what you're trying to achieve.
itaiferber
2010-10-05 03:32:15