[osg-users] osgGA::GUIEventHandler problem

25 views
Skip to first unread message

Ku Krapox

unread,
Jun 23, 2010, 6:09:38 AM6/23/10
to osg-...@lists.openscenegraph.org
Hi,

I keep having this strange behavior with my custom osgGA::GUIEventHandler class : the handle() method is executed twice each time I click on the handled object... I'm catching PUSH events only, and every single click on my object results in two runs in the corresponding block of the handle() method.

The first idea would be that my EventHandler is added twice on my object but it is NOT the case. I'm setting it inside the constructor of another object, which is instanciated only once in the whole app.

My handled object is inside an osg::Camera, could it be because of this? Picking objects inside a camera is tricky, but I managed to do it. The only problem is that they are picked twice... does a camera generate two PUSH events when clicked?

So here I am... Does anyone have a clue on what's wrong with my handler? Or how I could debug it?

Thanks! :)

Cheers,
Ku

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=29301#29301

_______________________________________________
osg-users mailing list
osg-...@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Martin Naylor

unread,
Jun 23, 2010, 1:04:34 PM6/23/10
to osg-...@lists.openscenegraph.org
Hi Ku,
Not sure about the below, but could it be that you are getting two clicks
because you are receiving one on the first click and one on release?
You may need to post some code of your event handler.

Hope it helps

Martin Naylor

Ku Krapox

unread,
Jun 24, 2010, 8:45:35 AM6/24/10
to osg-...@lists.openscenegraph.org
Hi,
Thanks for the reply!

I actually managed to solve the problem, although I'm not sure of what caused it! :)

Here's the code for my handler, may it help someone in the same case :


Code:
bool CRightPanelEventHandler::handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa, osg::Object* object, osg::NodeVisitor* nv)
{
if (nv->getFrameStamp() != NULL && nv->getFrameStamp()->getFrameNumber() != _lastFrame)
{
_lastFrame = nv->getFrameStamp()->getFrameNumber();

if (ea.getEventType() == osgGA::GUIEventAdapter::PUSH)
{
// Stuff
}
}
}

Checking and recording the framestamp at each loop avoids processing a same frame two times. But I have no idea why my handler processed each frame two times...

Cheers,
Ku

------------------
Read this topic online here:

http://forum.openscenegraph.org/viewtopic.php?p=29360#29360

Serge Lages

unread,
Jun 24, 2010, 8:56:25 AM6/24/10
to osg-...@lists.openscenegraph.org
Hi,

We had the same problem here, with an event callback on a camera, the push event was called two times, and we solved it with the same method as you, we didn't found time to investigate further.

Cheers,
Reply all
Reply to author
Forward
0 new messages