How to get the current eventNumber for creating an event with NSEvent
Posted
by Chris
on Stack Overflow
See other posts from Stack Overflow
or by Chris
Published on 2010-04-18T11:56:29Z
Indexed on
2010/04/18
12:03 UTC
Read the original article
Hit count: 309
Hello I'm creating an os x application for which I try to add a remote interface. For this I need to be able to send mouse down and mouse up commands to the window of my application.
I found code with which I can successfully do this, it looks as follows:
int mask = 0x100;
NSEvent* eventMouseDown = [NSEvent mouseEventWithType:NSLeftMouseDown
location:p
modifierFlags:mask
timestamp:[NSDate timeIntervalSinceSystemStartup]
windowNumber:[w windowNumber]
context:[NSGraphicsContext graphicsContextWithWindow:w]
eventNumber:++eventCounter +42599 clickCount:1 pressure:0];
NSLog(@"Mouse down event: %@", eventMouseDown);
[[NSApplication sharedApplication] sendEvent:eventMouseDown];
I have only one problem with this code thought and this is the eventNumer parameter. As far as I found out it is a number which get increased with each event. But I cannot find a way to find the current number from where on I need to increase. The number I use there currently is just try and error and also does not seam to work always.
© Stack Overflow or respective owner