Typing in 3D Widget.
So, how can I make it so that the player can type inside of EditableTextBox widget's without a virtual keyboard, and without creating an event for every single key on the keyboard executing a "Send Key Char" BP node.
How can I make it so that it is like it was before, where a player clicks on an EditableTextBox, and the player uses their actual keyboard to type and delete etc?
My game has a tonne of interaction in it; almost everything is interactive, and that includes computer terminals. I even have my own little mini OS in built in the game which recognizes command lines that are typed in on the computer terminal for in game "hacking" purposes. I have been OK with using 3D widgets up until today, when I discovered that 4.13 overrides the old way of 3D widget interaction with a new method, which seemed ok when I got it working properly....it was relatively painless.
Previously, in order for the player to interact with a 3d widget, the 3d widget was part of a blueprint, with a mesh (computer mesh) and the player could click on the mesh. The blueprint implemented an interface so that there was an event call when the player would click on the mesh, and the 3d widget blueprint would then set the Input mode to game and UI, so the player could interact with the 3d widget. (that probably made no sense)
The problem I am now faced with, is that I cannot type on any of the computer terminals how I normally would, and this is really problematic, considering how critical this type of interaction is in my game.
I am here to ask how I can go about making a simple way for the player to type onto a 3D widget (a virtual keyboard isn't the answer either).
I noticed when dragging off the WidgetInteraction component node in my player class blueprint, there is a node called press key, I thought this might help, but it suggested using "Send Key Char"....but it really doesn't explain how to use this Send Key Char node, and now i'm quite confused and bummed, because my computer interaction system was all working, and now I am stuck with how I can go about updating it to this new method of 3D widget interaction.
UPDATE: This is what I have to do to try and type in an editableTextbox now...and this really doesn't work very well. For example, I can't use the delete key, because it creates a ".", or at the moment, I can't use arrow keys to move through the text. I also can't hold shift and highlight text and do text modifiers without doing a bunch of blueprint scripting....and even then, it's going to feel hacky and probably easily breakable. Here is what I have done so far in my player blueprint.
I had trouble with this as well. I think the expected behaviour would be to give keyboard focus to a textbox when clicked, but I can understand the reasoning for how Epic did it as well.
Anyway, I found a solution which is a little less hacky, and works quite well for me. The only problem is that I get a log error: LogWindowsTextInputMethodSystem:Error: Activating a context failed while setting focus on a TSF document manager. The parameter is incorrect. (0x80070057) whenever I click in the text box.
Here's what I did. In the widget blueprint, I created an array with all textboxes and manually populate it with any textboxes in the widget. (IIf anyone knows how to get and iterate over all widgets in a widget blueprint and then check if their class is textbox, I'd like to know.)
Then, in the pawn that has the widget interaction component, on left mouse button I do the standard click sending, and then I go over the array to see if any of those stored textboxes are hovered. If so, that means the user clicked on that textbox. Then I set keyboard focus to that textbox. It automatically removes focus when you're done typing and click somewhere else. I have to cast in order to get the array though, so it's not exactly universal. But you could have a parent WBP with the textboxes array that your other WBPs inherit from, and then cast to that parent instead.
Here are the BP graphs:
It would be really nice and handy if you could check exactly which widget element is being hovered on by the Widget Interaction Component, not just which entire widget blueprint. Then that code could be simplified heavily to just check on the hovered element. If anyone knows how to do this, let me know.
If the player uses the actual keyboard and slate sends input to it directly - that effectively breaks input to the game. That's why it doesn't work that way any more. If you've got a situation where you don't care about that, you'll need to modify the WIC code, or copy it and make your own version of it. Essentially you need to set focus as Slate User 0, instead of the slate user index you're assigned based on the virtual user index. That will change the focus of Slate for the hardware mouse and keyboard user, placing it onto whatever widget you click.
answered Sep 06 '16 at 04:33 PM
Nick Darnell ♦♦ STAFF
Follow this question
Once you sign in you will be able to subscribe for any updates here