【发布时间】:2010-02-26 08:59:47
【问题描述】:
我的 iPhone 上有一个虚拟触控板,我正在使用移动鼠标:
CGDisplayMoveCursorToPoint(kCGDirectMainDisplay, CGPointMake(((float)aD.msg)+location.x, ((float)aD.msg2)+location.y));
它运行良好,但这不是真正的鼠标,因为当我将鼠标放在隐藏的底座上时,它不会自行显示。我不明白为什么。 此外,我尝试使用以下方法模拟鼠标点击:
case MOUSECLICK:
[self postMouseEventWithButton:0 withType:kCGEventLeftMouseDown andPoint:CGEventGetLocation(CGEventCreate(NULL))];
[self postMouseEventWithButton:0 withType:kCGEventLeftMouseUp andPoint:CGEventGetLocation(CGEventCreate(NULL))];
// *********************
-(void)postMouseEventWithButton:(CGMouseButton)b withType:(CGEventType)t andPoint:(CGPoint)p
{
CGEventRef theEvent = CGEventCreateMouseEvent(NULL, t, p, b);
CGEventSetType(theEvent, t);
CGEventPost(kCGHIDEventTap, theEvent);
CFRelease(theEvent);
}
这是好方法吗?感谢您的帮助!
【问题讨论】:
标签: iphone macos mouse mouseevent