Home | Tutorials | Wiki | Issues
Ask Your Question
1

How to return the controlling to default event handler?

asked 2015-04-17 01:32:06 -0600

Zheng yo chen gravatar image

updated 2015-04-17 01:34:20 -0600

Given that I had installed my own mouse event handler,

but how can I return the controlling to default/system event handler?

Because after installing my own mouse event handler,

and I pressed toolbar to add a sphere/box/cylinder to world

it turned out that the sphere/box/cylinder could not be released and placed on the ground

becuase "Mouse Release Event" is handled by my own mouse handler,default/system event handler cannot listen to this event

How can I deal with this problem?

Thank you~

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2015-04-17 12:44:34 -0600

updated 2015-04-20 01:11:27 -0600

I'm assuming you added an event handler with AddReleaseFilter, like this for example:

MouseEventHandler::Instance()->AddReleaseFilter("my_plugin",
    boost::bind(&MyPlugin::OnMouseRelease, this, _1));

Your function returns a bool which indicates if the event was handled or not. So if you return false, the event will be propagated onwards. Return true to stop propagation.

bool MyPlugin::OnMouseRelease(const common::MouseEvent &_event)
{
  // Do what you want to do and decide if you want to propagate the event

  if (propagateEvent)
    return false;
  else
    return true;
}
edit flag offensive delete link more

Comments

thank you,but It did not work :( ;both OnMouseRelease and OnMousePress are return by false

Zheng yo chen gravatar imageZheng yo chen ( 2015-04-17 22:53:01 -0600 )edit

and I have another question,why I must use "glwidget" as the fisr parameter in AddPressFilter("glwidget"....)? If I change to this AddPressFilter("mysysgui"....), then my mouse handler can not be called

Zheng yo chen gravatar imageZheng yo chen ( 2015-04-17 22:54:17 -0600 )edit

If you use "glwidget" as the first parameter, you're probably overriding the GLWidget's event handler, which is responsible for releasing shapes for example, so that's why this is not working for you. It should work with a custom string. Is your plugin a GUI Plugin?

chapulina gravatar imagechapulina ( 2015-04-20 01:10:44 -0600 )edit

Hi thank you,but if I change name other than "glwdiget", my mouse handler can not work. I am running gazebo 2.2 and use SystemPlugin,thank you~

Zheng yo chen gravatar imageZheng yo chen ( 2015-04-21 01:04:43 -0600 )edit

I just confirmed this is an issue with System Plugins and created an issue. I also checked that it works as expected with GUI plugins, so meanwhile you could work around this using a GUI plugin at least just for the events.

chapulina gravatar imagechapulina ( 2015-04-23 22:24:47 -0600 )edit

so, in conclusion ,there is no available solution for SystemPlugin? And, gazebo 2.2 doesn't have GUIplugin, my only choice is updatint to gazebo 5.0 or higher?Thanks~

Zheng yo chen gravatar imageZheng yo chen ( 2015-04-25 22:45:37 -0600 )edit

Yes, I think so.

chapulina gravatar imagechapulina ( 2015-04-26 17:06:27 -0600 )edit

ok Thank you~

Zheng yo chen gravatar imageZheng yo chen ( 2015-04-28 02:49:16 -0600 )edit
Login/Signup to Answer

Question Tools

Stats

Asked: 2015-04-17 01:32:06 -0600

Seen: 299 times

Last updated: Apr 20 '15