I’m trying to do one simple thing; give the game viewport keyboard focus after I hide a panel containing an EditableTextBox. This isn’t happening. I’ve tried the ClearKeyboardFocus and SetFocusToGameViewport nodes with no luck, and also tried putting in a small delay.
On a key press, if it’s not already open, the panel containing the EditableTextBox is set to visible and given focus so you can start typing immediately. This works fine.
On text commit, using a ‘Switch on ETextCommit’ node, I have it set the text box to hidden (after handling the text entered). Then I’d like to be able to press the key again to re-open said EditableTextBox and type in it again, without having to click the mouse button. At the moment, I have to click in the viewport after closing the text box before I can open it again.
Does anyone know a fix for this? Many thanks in advance
There is a node SetKeyboardFocus, if you target the editable box, it should work. In case this does not work or it not something you’re after, could you clarify where the keystrokes are originating from? Controller or the widget itself?
this i show i do it in my project in my player controller i create a on enter pressed event .
when the enter key is pressed it calls a custom event inside the widget i am trying to focus.
then like everynone suggested here you just use the set keyboard focus
the branch is for checking if the widget already has focus in which case we dont do anything but if it doesnt have focus it sets the focus to the widget. in my case i am also at the same time setting the visibility of another widget this is because in my game i have another function that hides the chat system when not in use .
Try EniGmaa’s solution first. I don’t really know, if this will help, but there are 3 nodes, which could be of help. They should be self explanatory by their names.
It doesn’t exactly focus your keyboard, but it forces the widget to get into certain modes and changes the focus behaviour of the widget.