views:

31

answers:

1

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
can you show an example?
Elijah W.
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