Thank you Robert! Now everything is Ok! On Tuesday 03 July 2007 16:18, Robert Osfield wrote: > Hi Panagiotis, > > The behavior difference you are seeing is down to the osgViewer using > the Chain of Responsibility Design Pattern for passing on events, the > just of it is that viewer passes events to all event handlers > regardless of whether the event has been handled or not. The approach > pushes the responsibility for checking to see if the event has been > handled on to the event handlers themselves. They can check this via > the GUIEventAdapter::getHandled() method. If an event handler returns > true then the Handled bool is automatically set to true. > > The problem that you have observed arises when an event handler has > been updated to filter out already handled events, some of the osgGA > event handles like the camera manipulators had been updated, but not > all - the osgGA::StatsManipulator and osgViewer::ViewerEventHandlers > hadn't been updated for 2.0. I have just gone through these event > handlers and added in the appropriate code - mostly checks like: > > if (ea.getHandled()) return false; > > Added to the *::handle(..) methods. > > With this change your code example: > > int main(int , char **) > { > osgViewer::Viewer viewer; > > osg::ref_ptr<KeyboardModel> keyboardModel = new KeyboardModel; > > viewer.addEventHandler(new KeyboardEventHandler(keyboardModel.get())); > viewer.addEventHandler(new osgViewer::StatsHandler); > viewer.setSceneData( keyboardModel->getScene() ); > > return viewer.run(); > } > > Will result in the StasHandler getting events but discarding them as > they have already been handled by the KeyboardEventHandler. If > however, you change the order, then the stats will work and the > keyboard handler will work as the later doesn't check for > getHandled(). In this instance this is what you want, and the new > Chain of Responsibility approach is working as intended giving you the > flexibility to control how events are handled. > > Robert. > > On 7/3/07, Panagiotis Papadakos <[EMAIL PROTECTED]> wrote: > > Well I modified the osgkeyboard example, and added a StatHandler so that > > main now is: > > > > int main(int , char **) > > { > > osgViewer::Viewer viewer; > > > > osg::ref_ptr<KeyboardModel> keyboardModel = new KeyboardModel; > > > > viewer.addEventHandler(new > > KeyboardEventHandler(keyboardModel.get())); viewer.addEventHandler(new > > osgViewer::StatsHandler); > > viewer.setSceneData( keyboardModel->getScene() ); > > > > return viewer.run(); > > } > > > > But still pressing s, presses the s key in the virtual keyboard and also > > shows stats. > > > > I didn't have this problem with osgProducer::Viewer but appeared when I > > ported to osgViewer::Viewer. > > > > On Monday 02 July 2007 21:48, Jeremy L. Moles wrote: > > > On Mon, 2007-07-02 at 21:32 +0300, Panagiotis Papadakos wrote: > > > > Hi Jeremy and thanks for your quick response. > > > > > > > > I think you have a point there. But even if I inverse my handler, > > > > things again do not work. I also tried setting setHandled to true but > > > > again nothing! > > > > > > I looked at the code and StatsHandler works on KEYDOWN; so, just make > > > sure your event handler is front of the StatsHandler when you add it > > > to the viewer (either by hand or by calling push_front()) and return > > > true on that event and you should be okay. Alternatively, you can call: > > > > > > statsHandler->setKeyEventTogglesOnScreenStats() > > > > > > ...to change it from S to something else. > > > > > > > On Monday 02 July 2007 21:04, Jeremy L. Moles wrote: > > > > > On Mon, 2007-07-02 at 20:55 +0300, Panagiotis Papadakos wrote: > > > > > > Hello everybody! > > > > > > > > > > > > I have an OSGKeyboardEventHandler : public osgGA::GUIEventHandler > > > > > > keyboard handler, whose handle method returns true when for > > > > > > example 's' is pressed. My problem is that because I have also > > > > > > added the osgViewer::StatsHandler to my viewer i also see the > > > > > > stats printed on my screen! Am I doing something wrong? Thank > > > > > > you. > > > > > > > > > > I would guess that one does key press (perhaps yours), and the > > > > > other release (perhaps StatsHandler). I haven't checked the source > > > > > to confirm, but I bet this is what is happening... > > > > > > > > > > _______________________________________________ > > > > > osg-users mailing list > > > > > osg-users@openscenegraph.net > > > > > http://openscenegraph.net/mailman/listinfo/osg-users > > > > > http://www.openscenegraph.org/ > > > > -- > > Papadakos Panagiotis > > _______________________________________________ > > osg-users mailing list > > osg-users@openscenegraph.net > > http://openscenegraph.net/mailman/listinfo/osg-users > > http://www.openscenegraph.org/ > > _______________________________________________ > osg-users mailing list > osg-users@openscenegraph.net > http://openscenegraph.net/mailman/listinfo/osg-users > http://www.openscenegraph.org/
-- Papadakos Panagiotis _______________________________________________ osg-users mailing list osg-users@openscenegraph.net http://openscenegraph.net/mailman/listinfo/osg-users http://www.openscenegraph.org/