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"

Losing keyboard focus on mouse click

  1. I made a custom player controller, where I disabled "show mouse cursor", click events, mouse over events, generally all mouse input options.

  2. I made UMG Huds in which I can navigate just by keyboard.

  3. But when I click left mouse button whenever the umg is active, it loses keyboard focus and therefore it's not responsive. I have to close this umg and open it again to navigate.

So how can I completely disable mouse input in my game? Even when I do recommended steps, it's still present and disrupts my design.

Product Version: UE 4.11
Tags:
more ▼

asked May 26 '16 at 03:59 PM in Using UE4

avatar image

andrzejBG
100 7 8 14

avatar image TheAgent Aug 21 '16 at 09:27 PM

I have the same question.

avatar image CleanCut Nov 22 '16 at 08:23 PM

This affects me too. In my case, I just don't want my focused widgets to lose focus when the mouse clicks somewhere that shouldn't be clickable.

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

3 answers: sort voted first

my work around has been to check if all the buttons have user focus (making them into an array and then checking if each one has focus, and if none have any focus set it to the correct button) but this workaround takes long to implement on complex menu systems... seriously there has to be a better way

more ▼

answered May 16 '17 at 05:01 AM

avatar image

Imagine-Games
224 5 11 15

avatar image Ryan Darcey May 26 '17 at 06:54 PM

i'm doing the same exact thing. it is not a great work around, but i can't find a better solution :'(

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

are you doing this for single player or local multiplayer, the reason i ask is if you want it for the local multiplayer the logic only needs to follow the 1st players buttons, becausr if he clicks and the focus is lost everyones fpcus is also lost so just reset everyones buttons to their default focus if player 1 loses focus (that way you only make an array of p1's buttons...)

more ▼

answered May 26 '17 at 08:00 PM

avatar image

Imagine-Games
224 5 11 15

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

Fixed that doing some voodoo magic in overriding virtual void NativeOnFocusChanging(const FWeakWidgetPath& PreviousFocusPath, const FWidgetPath& NewWidgetPath, const FFocusEvent& InFocusEvent) override;

in UserWidgetEx.h

 #pragma once
 
 #include "Blueprint/UserWidget.h"
 #include "UserWidgetEx.generated.h"
 
 
 
 UCLASS()
 class UNREALENGINEEX_API UUserWidgetEx : public UUserWidget
 {
     GENERATED_BODY()
 
 
 public:
     UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Interaction", meta = (Bitmask, BitmaskEnum = "EFocusCause"))
     int32 PreventFocusChange;
 
 
 public:
     UUserWidgetEx(const FObjectInitializer& ObjectInitializer);
 
 
 protected:
     virtual void NativeOnFocusChanging(const FWeakWidgetPath& PreviousFocusPath, const FWidgetPath& NewWidgetPath, const FFocusEvent& InFocusEvent) override;
 };
 

in UUserWidgetEx.cpp

 #include "UnrealEngineExPrivatePCH.h"
 #include "UserWidgetEx.h"
 
 #include "Framework/Application/SlateApplication.h"
 
 
 
 UUserWidgetEx::UUserWidgetEx(const FObjectInitializer& ObjectInitializer)
     : Super(ObjectInitializer)
 {
 }
 
 void UUserWidgetEx::NativeOnFocusChanging(const FWeakWidgetPath& PreviousFocusPath, const FWidgetPath& NewWidgetPath, const FFocusEvent& InFocusEvent)
 {
     if (((PreventFocusChange & 1 << InFocusEvent.GetCause()) != 0) && PreviousFocusPath.GetLastWidget() == TakeWidget())
     {
         int32 UserIndex;
         FSlateUser* SlateUser = nullptr;
         FSlateApplication::Get().ForEachUser([UserIndex, &SlateUser](FSlateUser* User) { if (UserIndex == User->GetUserIndex()) SlateUser = User; });
 
         if (SlateUser)
         {
             SlateUser->UpdateFocusVersion();
             return; // success on preventing focus switch.
         }
     }
     
     Super::NativeOnFocusChanging(PreviousFocusPath, NewWidgetPath, InFocusEvent);
 }

subclass your widgets from this class. and set PreventFocusChange to Mouse

more ▼

answered Jun 13 '19 at 11:52 AM

avatar image

Yata
554 41 50 69

(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