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"

Set Input Mode Game and UI errors

Hi! There seems to be some problems with the blueprint function "Set Input Mode Game and UI":

  1. Lock mouse to viewport does not work if the Function is placed in the level blueprint. By not working i mean there is a lock to the window instead of the viewport and if you click on something else than the window frame (for example the viewport) the lock ist immediately lost. Instead it has to be placed in the widget whicht it refers to. Even if the references are the same, it works there - more or less. alt text

  2. If you call the function in the widget after a "Event Construct" I get the error message "Infinite Loop detected in blueprint" Other events do not produce this error.alt text

  3. If the Function is called from within the widget by a "Event On Mouse Enter" the mouse is correctly locked inside the Viewport. However if the coursor is on the edge of the viewport and moved towards it, clicking leads to the cursors escape from the viewport.

The workaround is simply to call the function in the widget every tick. It is still possible for the cursor to escape the lock but it happed to me only once in a hundred clicks. BUT this blocks every mouse input to the game...alt text

I could not tag this with "Set Input Mode Game and UI" because I do not have enough reputiation. Could some Moderator add this for me please?

[edit] Almost forgot the Build: 4.6.1-2386410

Hope I could provide sufficient information to resolve this issue. Thanks for the otherwise great software!


Product Version: Not Selected
levelblueprint.jpg (61.9 kB)
mouselockloop.jpg (81.7 kB)
working.jpg (64.7 kB)
more ▼

asked Jan 06 '15 at 02:01 AM in Bug Reports

avatar image

1 1 2 4

avatar image Wallhalla Jan 06 '15 at 10:06 AM

Woah, a lot of redundancy here my friend ;).

Just what exactly do you hope to achieve? You set up the Input to first show for UI then for Game inputevents. You do that twice in your LevelBP as well as in your Widget Construct. What you do next is Set up the same thing every Tick which is already set twice. So have a lot of nodes which do something already accomplished and end up not making any kind of changes.

Why do you think your LevelBlueprint shall create your UI Widget? Even more, you do not have any reference to that widget to update its content, if it shouldnt then you wont need some, but just in your second picture you reference self to the input. I would recommend to create a variable of this widget after its creation, here: in your LevelBP.

The Construct should just initialize the widgets content or bind some events but i think that a widget would not change the behaviour of input. Read a bit about Model-View-Controller(MVC)-Architecture.

oh... i end up writing too much again.

However, i would recommend the following:

  1. Create your ProtoHUDWidget(i call my Widgets "Widget" at the end to make it clear that this is not a HUDClass) within the PlayercontrollerClass and add a variable with the returnvalue.

  2. Add it to Viewport

  3. Now it depends whether your widget shall be interactive or not, i assume a PlayerHUD (showing stuff, like HealthBars, Compass a.s.o) wont. But because you wanna use "Set Input..." it seems you want to have an interaction (makes sense f.e. in RTS-Games), so where do you put this? For now you can put it right after Add to Viewport inside the PlayerController. This option is now valid right after begin play. Give your widget reference and a "self" for controller ref to it.

Try those 3 steps and tell me if its the stuff you want for now?

best regards

avatar image Azrl26 Jan 06 '15 at 03:54 PM

Hello Wallhalla and thank you for the quick reply!

The situation is following: We want to create an RTS game. The UI input would go to the widgtets with all its buttons and the Game input to the Camera to move it. The UI is standing and recieving input and the Camera is working. Scrolling however is hardly possible since the mouse just escapes the viewport and the scrolling area should just be about 3 pixels wide so I was looking for a way to lock the mouse cursor inside the viewport. I found this option in the "Set Input Mode Game and UI" but i just does not seem to work as I would have expected.

Please note that the three pictures show three different cases and the blueprint functions do not exist simultaneously! I just wantet to show what I did where for each Point in the Question.

I have put the "Create Widget" function in the level blueprint because I also set my Camera as source for the viewport (Set View Target), it was also shown this way in some tutorial. Is this wrong or is there a better place i can put this?

But yes, a Reference to the object is not needed, because there will not be change in the content of the widget.

Now i did follw your three steps and they resulted in the same error as described above under Point 1. The Lock ist there but on the window. There are only 2 things inside this window: Windowframe and Viewport and if i click somwhere in the latter the lock is lost. So the "Lock to viewport" has failed again. I tried it with a direct reference and a stored reference. Both resulted in the same error. The variable should not make any difference anyway from my point of view. Version directalt text

direct.jpg (75.8 kB)
viaref.jpg (144.6 kB)
avatar image Wallhalla Jan 06 '15 at 08:05 PM

Hey there, well i think there is no exact right or wrong, it always depends on what you wanna do, i dont wanna say you do something wrong, its just my point of view of doing it in an other way.

Im really sorry that i have no time left, but this one i want to tell you.

A UserWidget is an abstract class, so dont try to cast something into it. It should always return null, so the casting failed. Try out with a hook from Cast Failed -> new node Print String(String = "Cast failed") or use Breakpoints to view current values of an object (rightclick on a node->add breakpoint) press play and it stop at your breakpoints location, so you can investigate f.e. NULL-references. I want to answer your question: "Why do i need to cast this???" with another question:"Who told you to do this?" ;)

i will look up this tomorrow again ;)

best regards

avatar image Azrl26 Jan 06 '15 at 08:49 PM

UserWidget cannot be an abstract class since the "Create XY Widget" returns a UserWidget Reference which I pass to all the other functions. The type of the "Active Interface" was a Widget reference and not a UserWidget reference. I do not know why. When i promotet to variable again it worked. My fault it seems.

But we miss the point here. The Lock to viewport does not work and the infinite loop makes no sense to me.

Thanks for the time Wallhalla! Until tomorrow

avatar image Rudy Q ♦♦ STAFF Jan 06 '15 at 09:45 PM

Hello Azrl26,

I will start with the issue of the infinite loop. This is not a bug. The Widget is trying to get a self reference during the construct event but in order to fully construct it will need to get a self reference and it can't get a self reference until it has been constructed. This is also a circular dependency problem. To show you what I mean, place a delay node between the event construct and the "Set input Mode Game and UI" node and it should start up just fine. This is not meant to be a solution. It is a hacky way to show you what I mean. The delay will allow the Widget to finish construction before looking for a self reference.

As for the mouse not being locked to the viewport, I was unable to reproduce this issue. I could not get my mouse to leave the window after the "Set input Mode Game and UI" was called. I have a couple of questions that will help narrow down the issue that you are experiencing.

Quick questions:

  1. Can you reproduce this in a clean project?

  2. If you can reproduce this in a clean project, can you provide a detailed set of steps to reproduce this issue?

  3. Did you use commands such as Shift+F1 to get your mouse to leave the window?

Any addition information would be helpful.

avatar image Azrl26 Jan 07 '15 at 08:30 PM

Hi Rudy and hello again Wallhalla,

Concerning the infinite loop: I suspected as much but did not think this could be this way intentionally. I guess that is why this event is called "construct" and not "constructed". My mispinterpretation. Still, could a delay break a circular dependency?

As for the other Questions:

  1. Yes I can reproduce it

  2. No, I have a custom Player Controller so this option does not exist

  3. Text files are not allowed and I have too many characters to post it here so I had to take screenshotsalt text

[edit]I missed the seventeen... sorry alt text Hope I did not miss anything.

So from my point of view there are at least 2 Problems here:

  • The mouse does not lock to the viewport but the window.

  • The lock can be broken by moving the cursor against the edge and clicking wildly at the same time.

I suspect the click on the viewport breaks the lock because the viewport is not the lock target so i see this as consequential error.


Watch the picture again. I casted from Widget to UserWidget, not the other way around ;-)

I did not test if the casting failed though, but since the Widget was added to the viewport I do not think it failed.

Also I never set the Game Input Mode in more than one place. PC_Edgescrolling... well we started with the edge scrolling tutorial. It will be renamed/replaced later.

The Multiplayer is a good point. As you've seen I used created the widget in the player controller in the guide above. I think the Example is as you suggested?

Thanks to both of you for your time and the help you provide!

page1.jpg (132.9 kB)
page2.jpg (179.4 kB)
avatar image Wallhalla Jan 08 '15 at 10:29 AM

"Watch the picture again. I casted from Widget to UserWidget, not the other way around ;-)".

Yes indeed that is exactly what you are doing wrong here. You create your Widget Active Instance which IS a child of UUserWidget, casting a child into parent is not meant to be in this case. Im also referring to this Bugreport. But it seems you can currently casting to a UserWidgetReference but FMPOV it shouldnt be able.

However having it like this: Example should work out just fine. I test that and its fine.

BUT i am able to reproduce your issue and it seems to have some kind of relationship to this: Bugreport

Everything is locked to viewport, but when i am at the edge of the window inEditor or Standalone PlayMode and start clicking while trying to get off the viewport, i happen that the focus to the PIE is lost.

I think this can be considered as a BUG too.

best regards

avatar image Azrl26 Jan 08 '15 at 05:51 PM


Yes, that is the way I managed to do it the second time. thank you two for your effort! I hope for a quick fix for our RTS!

Greetings Azrael

avatar image Wallhalla Jan 09 '15 at 07:10 AM

just to relieve myself a bit, because i couldnt sleep well... getting a reference of a UserWidget makes sense after all. Considering to have a function which handles different Widgets, would mean the function itself dont know at start what kind of widget will come, by giving a UserWidget reference means it will handle all possible widgets user-created coming in.

avatar image Wallhalla Jan 07 '15 at 07:50 AM

Hi there again ;)

First have a look at this if you dont believe me.

Second you try to cast upwards. A child into parent which is not meant to be. F.e. a vehicle can be a car, this is valid because the car can do everything a vehicle can. But a car cannot be casted into a vehicle, because there are variables, functions only a car can.

Your point: "returns a UserWidget reference" is right because your custom created widgets are always children of a UserWidget. If im wrong then the print string "Casting Failed" should not be executed on your screen.

As for my mentioned steps, have you disabled the logic you do in levelbp and ProtoHUD? i forgot to tell you that.

Next: you called your PlayerControllerBP: PC_EdgeScrolling? why? is there another PlayerControllerBP somewhere?

However i thought about that create widget stuff. When you create a Widget you give it a reference to the owning Playercontroller. Assuming your RTS will be a multiplayer later, its good to have the creation still inside PlayerController, it would have the effect that every instance of a PlayerController (player 1, player 2, player 3) will have its own widget to deal with. If you leave it in levelblueprint having more than one player, you would need to add a function which creates multiple widgets for each playercontroller.

For not having a reference to your created widget. This could be a problem when you want to hide your widgets. F.e. if you need that in a cutscene. Saying this does not mean you will have to do it this way, there can be other ways too.

Just to have mentioned it, the input mode just works fine in my projects.

  1. Disable every logic you have done so far regarding your UI or try it in a raw project.

  2. Create widget in PlayerController

  3. Add it to Viewport

  4. Setup Input Mode

  5. No logic inside your WidgetBP

when im home i can make you an example bp

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

1 answer: sort voted first

Hello Azrl26,

I was able to reproduce this issue. I have written up a report (UE-7293) and I have submitted it to the developers for further consideration. I will provide updates with any pertinent information as it becomes available. Thank you for your information and time.

Make it a great day

more ▼

answered Jan 08 '15 at 05:22 PM

avatar image

Rudy Q ♦♦ STAFF
47.5k 545 132 522

(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