Page 1 of 1

How can a Button get focus

Posted: Fri May 22, 2009 09:06
by FeiYun
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!

Re: How can a Button get focus

Posted: Fri May 22, 2009 09:32
by FeiYun
No One?

Re: How can a Button get focus

Posted: Fri May 22, 2009 14:15
by Jamarr
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.

Re: How can a Button get focus

Posted: Sat May 23, 2009 02:16
by FeiYun
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

Re: How can a Button get focus

Posted: Sun May 24, 2009 10:36
by scriptkid
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.

Re: How can a Button get focus

Posted: Mon May 25, 2009 01:41
by FeiYun
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.