MacGui tests: Remove references to CGPostMouseEvent
CGPostMouseEvent is obsolete and known to have "undocumented special cases and undesirable side effects." The newer Quatz API doesn't allow neither multiple mouse button events nor preserving the mouse cursor location. Change-Id: I121b02fd01e2990488b05e45431cbdc13589656e Reviewed-by: Morten Johan Sørvig <morten.sorvig@digia.com>
This commit is contained in:
parent
d7f8f7e078
commit
12981e70a8
@ -144,22 +144,25 @@ WidgetNavigator::~WidgetNavigator()
|
||||
|
||||
namespace NativeEvents {
|
||||
#ifdef Q_OS_MAC
|
||||
void mouseClick(const QPoint &globalPos, Qt::MouseButtons buttons, MousePosition updateMouse)
|
||||
void mouseClick(const QPoint &globalPos, Qt::MouseButtons buttons)
|
||||
{
|
||||
CGPoint position;
|
||||
position.x = globalPos.x();
|
||||
position.y = globalPos.y();
|
||||
|
||||
const bool updateMousePosition = (updateMouse == UpdatePosition);
|
||||
CGEventType mouseDownType = (buttons & Qt::LeftButton) ? kCGEventLeftMouseDown :
|
||||
(buttons & Qt::RightButton) ? kCGEventRightMouseDown :
|
||||
kCGEventOtherMouseDown;
|
||||
CGMouseButton mouseButton = mouseDownType == kCGEventOtherMouseDown ? kCGMouseButtonCenter : kCGEventLeftMouseDown;
|
||||
CGEventRef mouseEvent = CGEventCreateMouseEvent(NULL, mouseDownType, position, mouseButton);
|
||||
CGEventPost(kCGHIDEventTap, mouseEvent);
|
||||
|
||||
// Mouse down.
|
||||
CGPostMouseEvent(position, updateMousePosition, 3,
|
||||
(buttons & Qt::LeftButton) ? true : false,
|
||||
(buttons & Qt::MidButton/* Middlebutton! */) ? true : false,
|
||||
(buttons & Qt::RightButton) ? true : false);
|
||||
|
||||
// Mouse up.
|
||||
CGPostMouseEvent(position, updateMousePosition, 3, false, false, false);
|
||||
CGEventType mouseUpType = (buttons & Qt::LeftButton) ? kCGEventLeftMouseUp :
|
||||
(buttons & Qt::RightButton) ? kCGEventRightMouseUp :
|
||||
kCGEventOtherMouseUp;
|
||||
CGEventSetType(mouseEvent, mouseUpType);
|
||||
CGEventPost(kCGHIDEventTap, mouseEvent);
|
||||
CFRelease(mouseEvent);
|
||||
}
|
||||
#else
|
||||
# error Oops, NativeEvents::mouseClick() is not implemented on this platform.
|
||||
|
@ -86,11 +86,10 @@ private:
|
||||
(Implemented so far: mouseClick on Mac)
|
||||
*/
|
||||
namespace NativeEvents {
|
||||
enum MousePosition { UpdatePosition, DontUpdatePosition };
|
||||
/*
|
||||
Simulates a mouse click with button at globalPos.
|
||||
*/
|
||||
void mouseClick(const QPoint &globalPos, Qt::MouseButtons buttons, MousePosition updateMouse = DontUpdatePosition);
|
||||
void mouseClick(const QPoint &globalPos, Qt::MouseButtons buttons);
|
||||
};
|
||||
|
||||
class ColorWidget : public QWidget
|
||||
|
Loading…
Reference in New Issue
Block a user