1/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2018 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 KEYEVENTHANDLER
15#define KEYEVENTHANDLER 1
17#include <osg/StateSet>
20#include <osgGA/GUIEventHandler>
22#include <osgPresentation/SlideEventHandler>
24namespace osgPresentation
27class OSGPRESENTATION_EXPORT KeyEventHandler : public osgGA::GUIEventHandler
31 KeyEventHandler(int key, osgPresentation::Operation operation, const JumpData& jumpData=JumpData());
32 KeyEventHandler(int key, const std::string& str, osgPresentation::Operation operation, const JumpData& jumpData=JumpData());
33 KeyEventHandler(int key, const osgPresentation::KeyPosition& keyPos, const JumpData& jumpData=JumpData());
35 void setKey(int key) { _key = key; }
36 int getKey() const { return _key; }
38 void setOperation(osgPresentation::Operation operation) { _operation = operation; }
39 osgPresentation::Operation getOperation() const { return _operation; }
41 void setCommand(const std::string& str) { _command = str; }
42 const std::string& getCommand() const { return _command; }
44 void setKeyPosition(const osgPresentation::KeyPosition& keyPos) { _keyPos = keyPos; }
45 const osgPresentation::KeyPosition& getKeyPosition() const { return _keyPos; }
47 void setJumpData(const JumpData& jumpData) { _jumpData = jumpData; }
48 const JumpData& getJumpData() const { return _jumpData; }
50 virtual bool handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter& aa, osg::Object* object, osg::NodeVisitor* nv);
52 virtual void getUsage(osg::ApplicationUsage& usage) const;
59 osgPresentation::KeyPosition _keyPos;
60 osgPresentation::Operation _operation;