Hi Nadia,

On 24/6/09 11:43 AM, Nadia Comanici wrote:
Code:
#include<osgGA/GUIEventHandler>
class ObjectManipulator: public osgGA::GUIEventHandler
{
public:
        virtual bool handle(const osgGA::GUIEventAdapter&  ea, 
osgGA::GUIActionAdapter&  aa);
        virtual void accept(osgGA::GUIEventHandlerVisitor&  v)   { 
v.visit(*this); };
};

bool ObjectManipulator::handle(const osgGA::GUIEventAdapter&  
ea,osgGA::GUIActionAdapter&  aa)
{       
   switch(ea.getEventType())
   {
     case(osgGA::GUIEventAdapter::KEYDOWN):
     {
        switch(ea.getKey())
       {
         case 'w':
             std::cout<<  " w key pressed"<<  std::endl;
             return false;
             break;
         default:
             return false;
       }                        
     }
     default:
       return false;
   }
}


The problem is that it never gets inside the 
case(osgGA::GUIEventAdapter::KEYDOWN)
instruction; Do I need to include anything else? or why doesn't it work?

The handle() itself looks okay, but some things look odd:
- why did you overload the 'accept()' method?
  I don't know if it hurts but it's certainly not necessary.
- handle() should return 'true' when the event was handled

Cheers,
/ulrich
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to