root/OpenSceneGraph/trunk/include/osgGA/EventHandler @ 13890

Revision 13890, 2.3 kB (checked in by robert, 16 hours ago)

Changed the osgUI behaviour so that events are set to be handled by Widgets that have focus even if they don't directly use them.

Line 
1/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
2 *
3 * This library is open source and may be redistributed and/or modified under
4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
5 * (at your option) any later version.  The full license is in LICENSE file
6 * included with this distribution, and on the openscenegraph.org website.
7 *
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 * OpenSceneGraph Public License for more details.
12*/
13
14#ifndef OSGGA_EVENTHANDLER
15#define OSGGA_EVENTHANDLER 1
16
17#include <vector>
18
19#include <osg/NodeCallback>
20#include <osg/Drawable>
21#include <osg/ApplicationUsage>
22
23#include <osgGA/Export>
24#include <osgGA/GUIEventAdapter>
25#include <osgGA/GUIActionAdapter>
26
27
28namespace osgGA{
29
30/**
31EventHandler is base class for adding handling of events, either as node event callback, drawable event callback or an event handler attached directly to the view(er)
32*/
33
34class OSGGA_EXPORT EventHandler : public osg::NodeCallback, public osg::Drawable::EventCallback
35{
36public:
37
38        EventHandler() {}
39        EventHandler(const EventHandler& eh,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY):
40            osg::NodeCallback(eh, copyop),
41            osg::Drawable::EventCallback(eh, copyop) {}
42
43        META_Object(osgGA, EventHandler);
44
45        /** Event traversal node callback method. There is no need to override this method in subclasses of EventHandler as this implementation calls handle(..) for you. */
46        virtual void operator()(osg::Node* node, osg::NodeVisitor* nv);
47
48        /** Event traversal drawable callback method. There is no need to override this method in subclasses of EventHandler as this implementation calls handle(..) for you. */
49        virtual void event(osg::NodeVisitor* nv, osg::Drawable* drawable);
50
51        /** Handle event. Override the handle(..) method in your event handlers to respond to events. */
52        virtual bool handle(osgGA::Event* event, osg::Object* object, osg::NodeVisitor* nv);
53
54        /** Get the user interface usage of this event handler, i.e. keyboard and mouse bindings.*/
55        virtual void getUsage(osg::ApplicationUsage&) const {}
56
57protected:
58
59};
60
61}
62
63#endif
Note: See TracBrowser for help on using the browser.