How to un-subscribe Event?

For help with general CEGUI usage:
- Questions about the usage of CEGUI and its features, if not explained in the documentation.
- Problems with the CMAKE configuration or problems occuring during the build process/compilation.
- Errors or unexpected behaviour.

Moderators: CEGUI MVP, CEGUI Team

westpointer
Just popping in
Just popping in
Posts: 16
Joined: Sat Nov 15, 2008 13:12

How to un-subscribe Event?

Postby westpointer » Thu Apr 16, 2009 09:49

I use the following code to subscribeEvent:

Code: Select all

CEGUI::GlobalEventSet::getSingleton().subscribeEvent(CEGUI::Window::EventNamespace+'/'+CEGUI::Window::EventMouseEnters,
      CEGUI::Event::Subscriber(&SceneSheet::handleMouseEnters, this));


After this, I want to un-subscribe the "EventMouseEnters" event for specific windows, but I don't know how.

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Postby CrazyEddie » Thu Apr 16, 2009 10:46

Hi,

If you're subscribing via the global event set you can't exclude some items from causing the global event to fire, since it doesn't work that way.

Maybe the best solution would be to maintain a list of 'excluded' windows and check those yourself at the top of the event hander?

CE.

westpointer
Just popping in
Just popping in
Posts: 16
Joined: Sat Nov 15, 2008 13:12

Postby westpointer » Thu Apr 16, 2009 13:08

I get it, thanks. :)

Another question. Suppose I subscrib a normal event to a window, and later if I want to cancel the event I subscribed to the window, how to achieve this?

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Postby CrazyEddie » Thu Apr 16, 2009 13:57

Hi,

I should have answered this bit before, so sorry about that.

When you call the subscribeEvent function you are returned a CEGUI::Event::connection object. If you want to 'unsubscribe' you can use this object and call the 'disconnect' function.

Code: Select all

using namespace CEGUI;

Event::connection con = window->subscribeEvent("AnEvent", myHandler);
...
con->disconnect();


You can also use a ScopedConnection, this will auto-disconnect when the ScopedConnection object goes out of scope.

HTH

CE.

westpointer
Just popping in
Just popping in
Posts: 16
Joined: Sat Nov 15, 2008 13:12

Postby westpointer » Thu Apr 16, 2009 15:24

Thanks, it helps :D


Return to “Help”

Who is online

Users browsing this forum: No registered users and 27 guests