May be this is very simple to do, but I currently noob in CEGUI and didn't found needed methods in the API Reference... I try to do it with activate, but no result.
P.S.: Mouse is disabled in my project. Only keyboard currently (in the future it also will be disabled) may be used. As result I need to use manual (by programm) methods to control visual state of all objects.
How can I manually change states of buttons (hovered, pushed
Moderators: CEGUI MVP, CEGUI Team
- vinnythetrue
- Not too shy to talk
- Posts: 21
- Joined: Wed Aug 10, 2005 10:29
Re: How can I manually change states of buttons (hovered, pu
You can just fire events manually with the well-named "fireevent" method.
For exemple :
mpbutton->fireEvent( PushButton::EventMouseButtonDown, EventArgs() );
This should set the button in pushed state, and then some
mpbutton->fireEvent( PushButton::EventMouseButtonUp, EventArgs() );
... to go back to normal state.
Try play with different events to see what they do, and if you're not satisfied with'em, you still can bind your own methods to your own events
For exemple :
mpbutton->fireEvent( PushButton::EventMouseButtonDown, EventArgs() );
This should set the button in pushed state, and then some
mpbutton->fireEvent( PushButton::EventMouseButtonUp, EventArgs() );
... to go back to normal state.
Try play with different events to see what they do, and if you're not satisfied with'em, you still can bind your own methods to your own events

- lindquist
- CEGUI Team (Retired)
- Posts: 770
- Joined: Mon Jan 24, 2005 21:20
- Location: Copenhagen, Denmark
Re: How can I manually change states of buttons (hovered, pu
Calling fireEvent will only trigger user callbacks.
The concept given by vinny is good enough, but you have to use the input injection methods provided by 'System'.
injectMousePosition <-- inject this with a proper coordinate over the button you want to hover.
injectMouseDown <-- inject this with a LeftButton to enable pushed.
injectMouseUp <-- inject this to go back to hover.
and then make sure you inject a new mouse position somewhere not over the button to go back to normal.
It's a little cumbersome, but it's currently the only way.
Doing it like this will trigger usercallbacks you may have assigned to the actions as usual. and remember that you'll need to redraw the GUI for any visual change.
The concept given by vinny is good enough, but you have to use the input injection methods provided by 'System'.
injectMousePosition <-- inject this with a proper coordinate over the button you want to hover.
injectMouseDown <-- inject this with a LeftButton to enable pushed.
injectMouseUp <-- inject this to go back to hover.
and then make sure you inject a new mouse position somewhere not over the button to go back to normal.
It's a little cumbersome, but it's currently the only way.
Doing it like this will trigger usercallbacks you may have assigned to the actions as usual. and remember that you'll need to redraw the GUI for any visual change.
Re: How can I manually change states of buttons (hovered, pu
I try to do it. But I cannot determine position of the window in mouse units. I try to use getAbsolutePosition.But result for window (size 0.34x0.4) placed in center of the screen ( 1024x768 ) is 17.0,46.0.
Why? In the documentation for this metod written: "Return the window position in absolute metrics". In description of MetricMode: "Absolute Metrics are specified as whole pixels".
Why? In the documentation for this metod written: "Return the window position in absolute metrics". In description of MetricMode: "Absolute Metrics are specified as whole pixels".
- lindquist
- CEGUI Team (Retired)
- Posts: 770
- Joined: Mon Jan 24, 2005 21:20
- Location: Copenhagen, Denmark
Re: How can I manually change states of buttons (hovered, pu
Use getPixelRect instead. It gives you that info in screen space. getAbsolutePosition is a pixel position yes. But relative to the parent of the window in question. Not the screen.
look here for the details...
Code: Select all
Rect r = window->getPixelRect();
System::getSingleton().injectMousePosition(r.d_left, r.d_top);
look here for the details...
Re: How can I manually change states of buttons (hovered, pu
Thank you. It's working!
Return to “Modifications / Integrations / Customisations”
Who is online
Users browsing this forum: No registered users and 6 guests