From Daniel Sjölie, support for controlling which viewports are focusable i.e.
recive mouse/keyboard events.
This commit is contained in:
@@ -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<osgUtil::SceneView> sceneView;
|
||||
float viewport[4]; // Win-size-relative [0,1]
|
||||
|
||||
bool _focusable;
|
||||
|
||||
osg::ref_ptr<osgGA::CameraManipulator> _cameraManipulator;
|
||||
CameraManipList _cameraManipList;
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user