Added Dragger::s/getActivationModKeyMask(..) and Dragger::s/getActivationKeyEvent(...) methods to make it possible to have draggers that only respond when you press a specified modified key or standard key.

Changed the optional dragger in osgvolume to require the shift key to be pressed for the dragger to become active.
This commit is contained in:
Robert Osfield
2009-07-03 19:16:53 +00:00
parent cb1b874167
commit 6e6a7c960e
8 changed files with 287 additions and 164 deletions

View File

@@ -98,7 +98,6 @@ osg::Node* addDraggerToScene(osg::Node* scene, const std::string& name)
osgManipulator::Dragger* dragger = createDragger(name);
dragger->setHandleEvents(true);
osg::Group* root = new osg::Group;
root->addChild(dragger);
@@ -110,6 +109,17 @@ osg::Node* addDraggerToScene(osg::Node* scene, const std::string& name)
dragger->addTransformUpdating(selection);
// we want the dragger to handle it's own events automatically
dragger->setHandleEvents(true);
// if we don't set an activation key or mod mask then any mouse click on
// the dragger will activate it, however if do define either of ActivationModKeyMask or
// and ActivationKeyEvent then you'll have to press either than mod key or the specified key to
// be able to activate the dragger when you mouse click on it. Please note the follow allows
// activation if either the ctrl key or the 'a' key is pressed and held down.
dragger->setActivationModKeyMask(osgGA::GUIEventAdapter::MODKEY_CTRL);
dragger->setActivationKeyEvent('a');
return root;
}

View File

@@ -1477,6 +1477,7 @@ int main( int argc, char **argv )
#endif
dragger->setupDefaultGeometry();
dragger->setHandleEvents(true);
dragger->setActivationModKeyMask(osgGA::GUIEventAdapter::MODKEY_SHIFT);
dragger->addDraggerCallback(new DraggerVolumeTileCallback(tile.get(), tile->getLocator()));
dragger->setMatrix(osg::Matrix::translate(0.5,0.5,0.5)*tile->getLocator()->getTransform());