how to get the focus state of edit


19-06-2010 14:55:43

is there a simple method to get the focus state of eidt?(like edit->isfocuson)

what i want to do with the focus state of edit is that, when i check the focus state which is true, i will input something in the eidt but not pass the keycode to the game.
(for example, when i type w , i just input character w to the edit ,but not control my player to turn left)


19-06-2010 15:43:21

All inject*** methods return true if even was handled by MyGUI, for example injectMouseMove return true if mouse over active GUI element, injectKeyPress return true if some widget had key focus and got that event.

Also you can use
/** Is any widget have key focus */
bool InputManager::isFocusKey();

If you need to check not all, but only one specific widget use
/** Get key focused widget */
Widget* InputManager::getKeyFocusWidget();
Something like
if (my_edit == InputManager::getInstance().getKeyFocusWidget()) { /* do something */}


20-06-2010 13:55:38

thanks for your reply!

another related question.
how can i make the editable wighet to get focus.(like edit->setfocuson )

for example, what i want to do is that, when i type the enter key, the edit will setvisible(true) and setfocus(true), then i can type someword in the edit.
again when i type enter key, the edit will setvisible(false) and setfocus(false),, (just like a chat console)


20-06-2010 16:53:13