reusing existing API

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@74234 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Stefan Csomor
2013-06-13 14:04:41 +00:00
parent 56d85ddeec
commit e535481318
3 changed files with 17 additions and 23 deletions

View File

@@ -49,10 +49,6 @@ public:
int button = wxMOUSE_BTN_LEFT) int button = wxMOUSE_BTN_LEFT)
{ return MouseDragDrop(p1.x, p1.y, p2.x, p2.y, button); } { return MouseDragDrop(p1.x, p1.y, p2.x, p2.y, button); }
bool MouseClickAndDragTo(long x, long y, int button = wxMOUSE_BTN_LEFT);
bool MouseClickAndDragTo(const wxPoint& point, int button = wxMOUSE_BTN_LEFT)
{ return MouseClickAndDragTo(point.x, point.y, button); }
// Keyboard simulation // Keyboard simulation
// ------------------- // -------------------

View File

@@ -37,18 +37,7 @@ bool wxUIActionSimulator::MouseDblClick(int button)
return true; return true;
} }
bool wxUIActionSimulator::MouseClickAndDragTo(long x, long y, int button) bool wxUIActionSimulator::MouseDragDrop(long x1, long y1, long x2, long y2,
{
MouseDown(button);
MouseMove(x,y);
MouseUp(button);
return true;
}
#endif
bool
wxUIActionSimulator::MouseDragDrop(long x1, long y1, long x2, long y2,
int button) int button)
{ {
MouseMove(x1, y1); MouseMove(x1, y1);
@@ -59,6 +48,8 @@ wxUIActionSimulator::MouseDragDrop(long x1, long y1, long x2, long y2,
return true; return true;
} }
#endif
bool bool
wxUIActionSimulator::Key(int keycode, int modifiers, bool isDown) wxUIActionSimulator::Key(int keycode, int modifiers, bool isDown)
{ {

View File

@@ -202,27 +202,34 @@ bool wxUIActionSimulator::MouseDblClick(int button)
return true; return true;
} }
bool wxUIActionSimulator::MouseClickAndDragTo(long x, long y, int button) bool wxUIActionSimulator::MouseDragDrop(long x1, long y1, long x2, long y2,
int button)
{ {
CGPoint pos1,pos2;
pos1.x = x1;
pos1.y = y1;
pos2.x = x2;
pos2.y = y2;
CGEventType downtype = CGEventTypeForMouseButton(button, true); CGEventType downtype = CGEventTypeForMouseButton(button, true);
CGEventType uptype = CGEventTypeForMouseButton(button, false); CGEventType uptype = CGEventTypeForMouseButton(button, false);
CGEventType dragtype = CGEventTypeForMouseDrag(button) ; CGEventType dragtype = CGEventTypeForMouseDrag(button) ;
wxCFRef<CGEventRef> event( wxCFRef<CGEventRef> event(
CGEventCreateMouseEvent(NULL, downtype, GetMousePosition(), CGButtonForMouseButton(button))); CGEventCreateMouseEvent(NULL, kCGEventMouseMoved, pos1, CGButtonForMouseButton(button)));
if ( !event ) if ( !event )
return false; return false;
CGEventSetType(event,kCGEventMouseMoved);
CGEventPost(tap, event);
CGEventSetType(event,downtype); CGEventSetType(event,downtype);
CGEventPost(tap, event); CGEventPost(tap, event);
CGPoint pos;
pos.x = x;
pos.y = y;
CGEventSetType(event, dragtype); CGEventSetType(event, dragtype);
CGEventSetLocation(event,pos); CGEventSetLocation(event,pos2);
CGEventPost(tap, event); CGEventPost(tap, event);
CGEventSetType(event, uptype); CGEventSetType(event, uptype);