I want to focus a libGDX Textfield from the code without clicking on the Textfield.
Is there a way to do this?
I was having the same question, finally found the answer by looking at TextField code.
You can focus your text field by doing this:
stage.setKeyboardFocus(textField);
//show the keyboard
textField.getOnscreenKeyboard().show(true);
Hope this help someone.
在以下代码中用jtextfield替换组件的名称:
jtextfield.requestFocus();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.