From ea35796526c96e31f335519d9c258adb11f2dff3 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Wed, 22 Jan 2003 15:44:22 +0000 Subject: [PATCH] =?UTF-8?q?From=20Daniel=20Sj=C3=B6lie,=20support=20for=20?= =?UTF-8?q?controlling=20which=20viewports=20are=20focusable=20i.e.=20reci?= =?UTF-8?q?ve=20mouse/keyboard=20events.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/osgGLUT/Viewer | 6 ++++++ src/osgGLUT/Viewer.cpp | 4 +++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/include/osgGLUT/Viewer b/include/osgGLUT/Viewer index c5c701d89..c2a042416 100644 --- a/include/osgGLUT/Viewer +++ b/include/osgGLUT/Viewer @@ -93,6 +93,10 @@ class OSGGLUT_EXPORT Viewer : public Window, public osgGA::GUIActionAdapter void selectCameraManipulator(unsigned int pos, unsigned int viewport = 0); + /// Set focusable + void setFocusable( unsigned int viewp, bool focusable ) + { _viewportList[viewp]._focusable = focusable; }; + void prependEventHandler(osgGA::GUIEventHandler* handler,unsigned int viewport = 0); void appendEventHandler(osgGA::GUIEventHandler* handler,unsigned int viewport = 0); @@ -147,6 +151,8 @@ class OSGGLUT_EXPORT Viewer : public Window, public osgGA::GUIActionAdapter osg::ref_ptr sceneView; float viewport[4]; // Win-size-relative [0,1] + bool _focusable; + osg::ref_ptr _cameraManipulator; CameraManipList _cameraManipList; diff --git a/src/osgGLUT/Viewer.cpp b/src/osgGLUT/Viewer.cpp index 109a44275..7e97abae1 100644 --- a/src/osgGLUT/Viewer.cpp +++ b/src/osgGLUT/Viewer.cpp @@ -854,7 +854,9 @@ void Viewer::mouse(int button, int state, int x, int y) mask == osgGA::GUIEventAdapter::RIGHT_MOUSE_BUTTON)) { int focus = mapWindowXYToViewport(x,y); - if (focus >= 0 && focus != int(_focusedViewport)) + if (focus >= 0 + && _viewportList[(unsigned int)focus]._focusable + && focus != int(_focusedViewport)) setFocusedViewport(focus); }