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"

Trouble with input focus (UI vs Game)

Hello, I have a bit strange issues with focus or I think there is some basic functionality missing in UE.

Issue 1: I need some node like bool IsMouseOnWidget(); because when I click on HUD button my character moves to this location (RTS). How to properly make input ignored when I click on HUD button ?

Issue 2: After clicking on HUD button, focus is probably changed to "UI only" and I can not use keys to move camera, in order to be able use keys again I need to click on empty place (that probably changes focus back to "UI and Game".

I don't think that nodes Set Input Mode UI Only/UI and Game/Game Only are solution here. I tested all of them. Thank you :)

Product Version: UE 4.8
Tags:
more ▼

asked Sep 01 '15 at 04:32 PM in Using UE4

avatar image

nonder
136 13 22 33

avatar image DerChris Sep 20 '15 at 12:16 PM

I've the same problem (probably). Also no solution, but perhaps some of the info here can help you:

https://answers.unrealengine.com/questions/301638/49-bug-button-blocks-cursor-keys.html

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

1 answer: sort voted first

Issue 1 solution:

Custom BP node created in C++ (PlayerController class)

.h

 UFUNCTION(BlueprintCallable, Category = "Input") 
 bool IsMouseOnWidget() const;

.cpp

 bool ACOMGamePlayerController::IsMouseOnWidget() const
 {
     for (TObjectIterator<UWidget> WidgetItr; WidgetItr; ++WidgetItr)
     {
         if(WidgetItr->IsHovered())
         {
             return true;
         }
     }
     
     return false;
 }

Issue 2 solution:

You need to set every UMG widget to bFocusable = false in properties of widget, don't forget to set it for root too! Best way to debug focus is enabling visual rectangle in Project Settings > User Interface.

more ▼

answered Feb 27 '16 at 09:59 PM

avatar image

nonder
136 13 22 33

avatar image Lamentation Oct 20 '17 at 04:38 AM

could you elaborate on how part 1 works? i've tried multiple ways but still can't get it to work

avatar image nonder Oct 26 '17 at 07:55 PM

This code does not work in new versions, here is updated one. Btw. using object iterator is horrible solution, however I have not found better way.

 bool UCOMStaticLibrary::IsMouseOnWidget()
 {
     // @todo TObjectIterator is not nice
     for (TObjectIterator<UWidget> WidgetItr; WidgetItr; ++WidgetItr)
     {
         TSharedPtr<SWidget> SafeWidget = WidgetItr->GetCachedWidget();
 
         if (SafeWidget.IsValid() && SafeWidget->IsDirectlyHovered())
         {
             return true;
         }
     }
 
     return false;
 }
(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