notify the event loop that synthesized events are on the queue, wait for them to be available, also on OSX a double click has to be synthesized slightly differently
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@74163 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
d60957aac5
commit
cd0f218cdd
@ -25,6 +25,8 @@ bool wxUIActionSimulator::MouseClick(int button)
|
||||
return true;
|
||||
}
|
||||
|
||||
#ifndef __WXOSX__
|
||||
|
||||
bool wxUIActionSimulator::MouseDblClick(int button)
|
||||
{
|
||||
MouseDown(button);
|
||||
@ -35,6 +37,8 @@ bool wxUIActionSimulator::MouseDblClick(int button)
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
bool
|
||||
wxUIActionSimulator::MouseDragDrop(long x1, long y1, long x2, long y2,
|
||||
int button)
|
||||
|
@ -26,6 +26,8 @@
|
||||
#include "wx/osx/private.h"
|
||||
#include "wx/osx/core/cfref.h"
|
||||
|
||||
#include "wx/evtloop.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
@ -77,7 +79,39 @@ bool wxUIActionSimulator::MouseDown(int button)
|
||||
|
||||
CGEventSetType(event, type);
|
||||
CGEventPost(tap, event);
|
||||
wxCFEventLoop* loop = dynamic_cast<wxCFEventLoop*>(wxEventLoop::GetActive());
|
||||
if (loop)
|
||||
loop->SetShouldWaitForEvent(true);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool wxUIActionSimulator::MouseDblClick(int button)
|
||||
{
|
||||
CGEventType downtype = CGEventTypeForMouseButton(button, true);
|
||||
CGEventType uptype = CGEventTypeForMouseButton(button, false);
|
||||
wxCFRef<CGEventRef> event(
|
||||
CGEventCreateMouseEvent(NULL, downtype, GetMousePosition(), button));
|
||||
|
||||
if ( !event )
|
||||
return false;
|
||||
|
||||
CGEventSetType(event,downtype);
|
||||
CGEventPost(tap, event);
|
||||
|
||||
CGEventSetType(event, uptype);
|
||||
CGEventPost(tap, event);
|
||||
|
||||
CGEventSetIntegerValueField(event, kCGMouseEventClickState, 2);
|
||||
CGEventSetType(event, downtype);
|
||||
CGEventPost(tap, event);
|
||||
|
||||
CGEventSetType(event, uptype);
|
||||
CGEventPost(tap, event);
|
||||
wxCFEventLoop* loop = dynamic_cast<wxCFEventLoop*>(wxEventLoop::GetActive());
|
||||
if (loop)
|
||||
loop->SetShouldWaitForEvent(true);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -96,7 +130,10 @@ bool wxUIActionSimulator::MouseMove(long x, long y)
|
||||
|
||||
CGEventSetType(event, type);
|
||||
CGEventPost(tap, event);
|
||||
|
||||
wxCFEventLoop* loop = dynamic_cast<wxCFEventLoop*>(wxEventLoop::GetActive());
|
||||
if (loop)
|
||||
loop->SetShouldWaitForEvent(true);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -111,7 +148,10 @@ bool wxUIActionSimulator::MouseUp(int button)
|
||||
|
||||
CGEventSetType(event, type);
|
||||
CGEventPost(tap, event);
|
||||
|
||||
wxCFEventLoop* loop = dynamic_cast<wxCFEventLoop*>(wxEventLoop::GetActive());
|
||||
if (loop)
|
||||
loop->SetShouldWaitForEvent(true);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -126,6 +166,10 @@ wxUIActionSimulator::DoKey(int keycode, int WXUNUSED(modifiers), bool isDown)
|
||||
return false;
|
||||
|
||||
CGEventPost(kCGHIDEventTap, event);
|
||||
wxCFEventLoop* loop = dynamic_cast<wxCFEventLoop*>(wxEventLoop::GetActive());
|
||||
if (loop)
|
||||
loop->SetShouldWaitForEvent(true);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user