I have a simple Objective C function used to perform mouse events (single clicks):
void click(CGPoint pt, int clickCount) {
CGEventRef theEvent = CGEventCreateMouseEvent(NULL, kCGEventLeftMouseDown, pt, kCGMouseButtonLeft);
CGEventPost(kCGHIDEventTap, theEvent);
CGEventSetType(theEvent, kCGEventLeftMouseUp);
CGEventPost(kCGHIDEventTap, theEvent);
if (clickCount == 2) {
CGEventSetIntegerValueField(theEvent, kCGMouseEventClickState, 2);
CGEventSetType(theEvent, kCGEventLeftMouseDown);
CGEventPost(kCGHIDEventTap, theEvent);
CGEventSetType(theEvent, kCGEventLeftMouseUp);
CGEventPost(kCGHIDEventTap, theEvent);
}
CFRelease(theEvent);
}
The problem is that if the screen is zoomed (Control + Scroll) then the point where it's clicked is not where it should be (I guess it's using the coordinates based on the new viewport, but even so it doesn't make sense).
Is this a bug in the library? Is there anyway to be aware of the user zooming in and still click in the right place, even though if that means moving the screen viewport?