How can a Button get focus

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

FeiYun
Just popping in
Just popping in
Posts: 6
Joined: Fri May 22, 2009 09:01

How can a Button get focus

Postby FeiYun » Fri May 22, 2009 09:06

I want a button get the mouse focus when get into a new Window
Fun:activate() is not working

Is there other that I can use it like:getfocus()

Thank you!

FeiYun
Just popping in
Just popping in
Posts: 6
Joined: Fri May 22, 2009 09:01

Re: How can a Button get focus

Postby FeiYun » Fri May 22, 2009 09:32

No One?

Jamarr
CEGUI MVP
CEGUI MVP
Posts: 812
Joined: Tue Jun 03, 2008 23:59
Location: USA

Re: How can a Button get focus

Postby Jamarr » Fri May 22, 2009 14:15

Typically the 'focus' has absolutely nothing to do with the mouse. The mouse can move the focus, but they are not the same thing; the keyboard, typically, can also move the 'focus', but again the 'focus' is a separate entity. So what, exactly, do you mean when you say "mouse focus"??

Do you mean that you want to automatically move the mouse over the button when the window opens? If so, just re-position the mouse yourself. You can use Window::getPixelRect() to get the pixel position of the button, and then just set the mouse position based on that.

p.s. this is a Beginner question...this does not belong in the Advanced help forum.
If somebody helps you by replying to your thread, upvote him/her as a thanks! Make sure to include your CEGUI.log and everything you tried when posting! And remember that we are not magicians!

FeiYun
Just popping in
Just popping in
Posts: 6
Joined: Fri May 22, 2009 09:01

Re: How can a Button get focus

Postby FeiYun » Sat May 23, 2009 02:16

Thankyou my question is that the image Button has four state (NormalImage HoverImage PushedImage DisabledImage). what I want is when getinto
a FrameWindow, the Button in this FrameWindow show PushedImage but no NormalImage that was What I said "get mouse focus"
and How can I re-position the mouse I Can not find the true function
Thanks

User avatar
scriptkid
Home away from home
Home away from home
Posts: 1178
Joined: Wed Jan 12, 2005 12:06
Location: The Hague, The Netherlands
Contact:

Re: How can a Button get focus

Postby scriptkid » Sun May 24, 2009 10:36

FeiYun wrote:How can I re-position the mouse I Can not find the true function.


You could use the System::injectMousePosition() method: http://www.cegui.org.uk/api_reference/c ... 41d9f080c4

Cegui will manage showing the corresponding state imagery.

However as soon as you move the mouse for real, i think that the button jumps back to the normal state again. What you could do is trick the user by putting the hower image on the normal 'slot':

Code: Select all

myButton->setProperty("NormalImage", "set:mySet image:buttonHover");


So that, when the mouse moves for real, the normal state looks hovered. You should however find the best place in your code when to undo this trick and set the correct image name again.

HTH.
Check out my released snake game using Cegui!

FeiYun
Just popping in
Just popping in
Posts: 6
Joined: Fri May 22, 2009 09:01

Re: How can a Button get focus

Postby FeiYun » Mon May 25, 2009 01:41

Thank you
what I want is when a new FrameWindow is opened by user, user can look at that a button is been choosed
so the button shows pushedimage
So I try to change the normalimage and then Let Button looks like being choosed, then at right place change back again.

I will use method until I find the better.


Return to “Modifications / Integrations / Customisations”

Who is online

Users browsing this forum: No registered users and 10 guests