How to "pick" a widget by code?

Frader

18-05-2010 19:48:46

I'm trying to make a simple Edit widget for ingame chat. The widget is shown whenever the user presses Enter.

The problem is I would like the user to be able to directly type whatever he wants. What happens now is that the Edit widget appears and then the user needs to pick it with the mouse in order to be able to start typing into it. I've gone nuts trying to find a solution, but I can't really find any.

I started my project a while ago so i'm still using version 2.2.3 (i can consider updating if needed be).

mprestia

18-05-2010 21:22:06

I don't know if the exact code would be the same in the MyGUI version you are using, but try this immediately after showing the widget:


MyGUI::InputManager::getInstance().setKeyFocusWidget([insert widget name here]);


I was trying to do the same thing for a login page and the above code worked for me.

Altren

18-05-2010 21:57:31

Yup, use setKeyFocusWidget for setting and resetKeyFocusWidget for removing key focus from widget.

Frader

19-05-2010 01:09:43

That made it, thank you :D

You need to provide a pointer to the widget instead of it's name thought ;)

mprestia

19-05-2010 14:21:34

yeah, sorry, i meant the variable name, not the widget name.