x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

Typing in 3D Widget.

TL;DR

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.

CLICK FOR IMAGE OF BLUEPRINT alt text

Product Version: UE 4.13
Tags:
more ▼

asked Sep 06 '16 at 10:53 AM in Blueprint Scripting

avatar image

Otreum
244 18 26 38

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

2 answers: sort voted first

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:

http://imgur.com/a/CcAD8

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.

more ▼

answered Sep 28 '16 at 06:14 AM

avatar image

Acriax
166 13 16 28

avatar image Davision Nov 06 '16 at 02:30 PM

There is a even better way, well far from how it supposed to work but anyway: In the graph of your widget make a Has Any User Focus with your desired editable text every tick, on true make it do Set Keyboard Focus. So when you click on it it it sets the Keyboard Focus. Pressing enter does not make it lose the focus though. But clicking anywhere else in the 3d widget does.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

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.

more ▼

answered Sep 06 '16 at 04:33 PM

avatar image

Nick Darnell ♦♦ STAFF
6k 77 37 151

avatar image Otreum Sep 07 '16 at 02:09 AM

Ah ok, thanks Nick.

I understand the reasoning for removing the code now. However may I suggest perhaps setting up some kind of switch that allows the older style of input, for when the player clicks on a EditableTextBox? (At least, that's what I'm going to aim for in creating a custom version of this class, that way I can still use this newer system too).

I am only just beginning to dive into the C++ side of things in UE4 as I believe it will give me greater flexibility and control over my project, but still really beginner level here haha.

I tried to create a custom version of the class, and set the parent class to be a WidgetComponent since I saw it was included in the header file, but I just got errors all over the place. Perhaps I need to make the parent class as a SceneComponent?

Thanks :)

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question