Event Behavior: Enabled vs Disabled

For help with anything that CEGUI doesn't offer straight out-of-the-box, e.g.:
- Implementation of new features, such as new Core classes, widgets, WindowRenderers, etc. ...
- Modification of any existing features for specific purposes
- Integration of CEGUI in new engines or frameworks and writing of new plugins (Renderer, Parser, ...) or modules

Moderators: CEGUI MVP, CEGUI Team

User avatar
Van
Just can't stay away
Just can't stay away
Posts: 225
Joined: Fri Jan 21, 2005 20:29
Contact:

Event Behavior: Enabled vs Disabled

Postby Van » Sun Oct 15, 2006 15:39

When the data/state of a widget is changed while disabled, why do events fire off when the widget is (re)enabled?

For example:
We have validation events subscribed to checkboxes (and other widgets too) that are tied to the CEGUI::Checkbox::EventCheckStateChanged event. When we are changing the checkbox, we DISABLE it because we don't want the event to fire. However, after we change the checkbox state and then ENABLE the checkbox the event fires PRIOR to the user changing the state of teh checkbox. It seems that the checkbox is instantly reacting to the state change while it was disabled. Is this behavior correct?

Implemenation:
This doesn't make since to us. We display data "as it is now" and then permit the user to change it. When a "change" occurs to the data we enable the "CANCEL and COMMIT" buttons. If the user hit's CANCEL, we disable all the widgets, reset the data back to "as it is now" and then re-enable the widgets. However, the "CHANGE" events are still being fired when the widget it is re-enabled. It makes more since that envents only fire when the widget is enabled. If the state changes while disabled, then don't fire the event.

User avatar
Gaal
Not too shy to talk
Not too shy to talk
Posts: 28
Joined: Thu Jul 21, 2005 03:36
Location: Ô Toulouse

Postby Gaal » Sun Oct 15, 2006 19:45

Instead of disabling the widget, try to use "setMutedState(true)" before you change any property, then "setMutedState(False)" after when you want the widget reacts again to your user.

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

Postby CrazyEddie » Sun Oct 15, 2006 19:45

To gaurantee that no events get fired, you should be using the method EventSet::setMutedState.

HTH

CE.

User avatar
Gaal
Not too shy to talk
Not too shy to talk
Posts: 28
Joined: Thu Jul 21, 2005 03:36
Location: Ô Toulouse

Postby Gaal » Sun Oct 15, 2006 19:46

I got it first .. :lol: :lol: :lol:

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

Postby CrazyEddie » Sun Oct 15, 2006 19:48

Bah!

:lol:


Return to “Modifications / Integrations / Customisations”

Who is online

Users browsing this forum: No registered users and 4 guests