]> git.saurik.com Git - wxWidgets.git/commitdiff
Applied #10753: WarpPointer() for Mac
authorJulian Smart <julian@anthemion.co.uk>
Fri, 25 Sep 2009 09:57:41 +0000 (09:57 +0000)
committerJulian Smart <julian@anthemion.co.uk>
Fri, 25 Sep 2009 09:57:41 +0000 (09:57 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@62116 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/osx/window_osx.cpp

index fe3f3a18bf04befcb32db6abb0e69d7da3b83e59..0c00c583e0dbd693a6f1a13b671bc463bc060a63 100644 (file)
@@ -1190,9 +1190,30 @@ wxWindow *wxGetActiveWindow()
 }
 
 // Coordinates relative to the window
-void wxWindowMac::WarpPointer(int WXUNUSED(x_pos), int WXUNUSED(y_pos))
-{
-    // We really don't move the mouse programmatically under Mac.
+void wxWindowMac::WarpPointer(int x_pos, int y_pos)
+{
+    int x = x_pos;
+    int y = y_pos;
+    DoClientToScreen(&x, &y);
+    CGPoint cgpoint = CGPointMake( x, y );
+    CGWarpMouseCursorPosition( cgpoint );
+
+    // At least GTK sends a mouse moved event after WarpMouse
+    wxMouseEvent event(wxEVT_MOTION);
+    event.m_x = x_pos;
+    event.m_y = y_pos;
+    wxMouseState mState = ::wxGetMouseState();
+
+    event.m_altDown = mState.AltDown();
+    event.m_controlDown = mState.ControlDown();
+    event.m_leftDown = mState.LeftDown();
+    event.m_middleDown = mState.MiddleDown();
+    event.m_rightDown = mState.RightDown();
+    event.m_metaDown = mState.MetaDown();
+    event.m_shiftDown = mState.ShiftDown();
+    event.SetId(GetId());
+    event.SetEventObject(this);
+    GetEventHandler()->ProcessEvent(event);
 }
 
 int wxWindowMac::GetScrollPos(int orient) const