1/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
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.
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.
14#ifndef OSGGA_GUIEVENTHANDLER
15#define OSGGA_GUIEVENTHANDLER 1
19#include <osg/Drawable>
20#include <osg/ApplicationUsage>
22#include <osgGA/EventHandler>
23#include <osgGA/GUIEventAdapter>
24#include <osgGA/GUIActionAdapter>
27// #define COMPILE_COMPOSITE_EVENTHANDLER
33GUIEventHandler provides a basic interface for any class which wants to handle
36The GUIEvent is supplied by a GUIEventAdapter. Feedback resulting from the
37handle method is supplied by a GUIActionAdapter, which allows the GUIEventHandler
38to ask the GUI to take some action in response to an incoming event.
40For example, consider a Trackball Viewer class which takes mouse events and
41manipulates a scene camera in response. The Trackball Viewer is a GUIEventHandler,
42and receives the events via the handle method. If the user 'throws' the model,
43the Trackball Viewer class can detect this via the incoming events, and
44request that the GUI set up a timer callback to continually redraw the view.
45This request is made via the GUIActionAdapter class.
49class OSGGA_EXPORT GUIEventHandler : public EventHandler
54 GUIEventHandler(const GUIEventHandler& eh,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY):
55 osg::Object(eh, copyop),
56 osg::Callback(eh, copyop),
57 EventHandler(eh, copyop) {}
59 META_Object(osgGA,GUIEventHandler);
61 /** Handle event. Override the handle(..) method in your event handlers to respond to events. */
62 virtual bool handle(osgGA::Event* event, osg::Object* object, osg::NodeVisitor* nv);
64 /** Handle events, return true if handled, false otherwise. */
65 virtual bool handle(const GUIEventAdapter& ea,GUIActionAdapter& aa, osg::Object*, osg::NodeVisitor*) { return handle(ea,aa); }
67 /** Deprecated, Handle events, return true if handled, false otherwise. */
68 virtual bool handle(const GUIEventAdapter&,GUIActionAdapter&) { return false; }
71 virtual ~GUIEventHandler();