|
Revision 9692, 2.3 kB
(checked in by robert, 4 years ago)
|
|
From Gary Quinn, spelling fixes
|
| Line | |
|---|
| 1 | |
|---|
| 2 | |
|---|
| 3 | |
|---|
| 4 | |
|---|
| 5 | |
|---|
| 6 | |
|---|
| 7 | |
|---|
| 8 | |
|---|
| 9 | |
|---|
| 10 | |
|---|
| 11 | |
|---|
| 12 | |
|---|
| 13 | |
|---|
| 14 | |
|---|
| 15 | |
|---|
| 16 | |
|---|
| 17 | |
|---|
| 18 | |
|---|
| 19 | |
|---|
| 20 | |
|---|
| 21 | |
|---|
| 22 | |
|---|
| 23 | |
|---|
| 24 | #include "AnimtkViewerKeyHandler" |
|---|
| 25 | |
|---|
| 26 | AnimtkKeyEventHandler::AnimtkKeyEventHandler() |
|---|
| 27 | { |
|---|
| 28 | _actionKeys[List] = 'l'; |
|---|
| 29 | _actionKeys[Help] = 'h'; |
|---|
| 30 | _actionKeys[Play] = 'p'; |
|---|
| 31 | _actionKeys[Next] = ']'; |
|---|
| 32 | _actionKeys[Prev] = '['; |
|---|
| 33 | } |
|---|
| 34 | |
|---|
| 35 | void AnimtkKeyEventHandler::printUsage() const |
|---|
| 36 | { |
|---|
| 37 | std::cout << (char) _actionKeys.find(Help)->second << " for Help" << std::endl; |
|---|
| 38 | std::cout << (char) _actionKeys.find(List)->second << " for List" << std::endl; |
|---|
| 39 | std::cout << (char) _actionKeys.find(Play)->second << " for Play" << std::endl; |
|---|
| 40 | std::cout << (char) _actionKeys.find(Next)->second << " for select Next item" << std::endl; |
|---|
| 41 | std::cout << (char) _actionKeys.find(Prev)->second << " for select Previous item" << std::endl; |
|---|
| 42 | } |
|---|
| 43 | |
|---|
| 44 | |
|---|
| 45 | bool AnimtkKeyEventHandler::handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter&, |
|---|
| 46 | osg::Object*, osg::NodeVisitor*) |
|---|
| 47 | { |
|---|
| 48 | AnimtkViewerModelController& mc = AnimtkViewerModelController::instance(); |
|---|
| 49 | if(ea.getEventType() == osgGA::GUIEventAdapter::KEYDOWN) |
|---|
| 50 | { |
|---|
| 51 | if (ea.getKey() == _actionKeys[List]) return mc.list(); |
|---|
| 52 | else if (ea.getKey() == _actionKeys[Play]) return mc.play(); |
|---|
| 53 | else if (ea.getKey() == _actionKeys[Next]) return mc.next(); |
|---|
| 54 | else if (ea.getKey() == _actionKeys[Prev]) return mc.previous(); |
|---|
| 55 | else if (ea.getKey() == _actionKeys[Help]) |
|---|
| 56 | { |
|---|
| 57 | printUsage(); |
|---|
| 58 | return true; |
|---|
| 59 | } |
|---|
| 60 | } |
|---|
| 61 | |
|---|
| 62 | return false; |
|---|
| 63 | } |
|---|