diff --git a/include/osgViewer/api/Carbon/GraphicsWindowCarbon b/include/osgViewer/api/Carbon/GraphicsWindowCarbon index 910eb56d3..7e9458406 100644 --- a/include/osgViewer/api/Carbon/GraphicsWindowCarbon +++ b/include/osgViewer/api/Carbon/GraphicsWindowCarbon @@ -92,6 +92,9 @@ class GraphicsWindowCarbon : public osgViewer::GraphicsWindow /** Set Window decoration.*/ virtual bool setWindowDecorationImplementation(bool flag); + // Override from GUIActionAdapter + virtual void requestWarpPointer( float x, float y); + /** Get focus.*/ virtual void grabFocus(); diff --git a/src/osgViewer/GraphicsWindowCarbon.cpp b/src/osgViewer/GraphicsWindowCarbon.cpp index faf00cc7e..31f4ff58f 100644 --- a/src/osgViewer/GraphicsWindowCarbon.cpp +++ b/src/osgViewer/GraphicsWindowCarbon.cpp @@ -1259,6 +1259,24 @@ void GraphicsWindowCarbon::setWindowName (const std::string& name) } } +void GraphicsWindowCarbon::requestWarpPointer(float x,float y) +{ + + OSXCarbonWindowingSystemInterface* wsi = dynamic_cast(osg::GraphicsContext::getWindowingSystemInterface()); + if (wsi == NULL) { + osg::notify(osg::WARN) << "GraphicsWindowCarbon::useCursor :: could not get OSXCarbonWindowingSystemInterface" << std::endl; + return; + } + + CGDirectDisplayID displayId = wsi->getDisplayID((*_traits)); + + CGPoint point; + point.x = x; + point.y = y; + CGDisplayMoveCursorToPoint(displayId, point); + + getEventQueue()->mouseWarped(x,y); +} void GraphicsWindowCarbon::transformMouseXY(float& x, float& y)