How can I manually change states of buttons (hovered, pushed

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
b-s-a
Just popping in
Just popping in
Posts: 10
Joined: Wed Nov 30, 2005 16:12
Location: Moscow, Russia
Contact:

How can I manually change states of buttons (hovered, pushed

Postby b-s-a » Wed Nov 30, 2005 16:50

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.

User avatar
vinnythetrue
Not too shy to talk
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

Postby vinnythetrue » Wed Nov 30, 2005 17:05

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 ;)

User avatar
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

Postby lindquist » Wed Nov 30, 2005 17:35

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.

User avatar
b-s-a
Just popping in
Just popping in
Posts: 10
Joined: Wed Nov 30, 2005 16:12
Location: Moscow, Russia
Contact:

Re: How can I manually change states of buttons (hovered, pu

Postby b-s-a » Thu Dec 01, 2005 14:28

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".

User avatar
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

Postby lindquist » Thu Dec 01, 2005 15:04

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.

Code: Select all

Rect r = window->getPixelRect();
System::getSingleton().injectMousePosition(r.d_left, r.d_top);


look here for the details...

User avatar
b-s-a
Just popping in
Just popping in
Posts: 10
Joined: Wed Nov 30, 2005 16:12
Location: Moscow, Russia
Contact:

Re: How can I manually change states of buttons (hovered, pu

Postby b-s-a » Thu Dec 01, 2005 18:35

Thank you. It's working!


Return to “Modifications / Integrations / Customisations”

Who is online

Users browsing this forum: No registered users and 4 guests