bTouchFallbackToMouse
bTouchFallbackToMouse
#Overview
name: bTouchFallbackToMouse
The value of this variable can be defined or overridden in .ini config files. 1
.ini config file referencing this setting variable.
It is referenced in 8
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of bTouchFallbackToMouse
is to control whether unhandled touch events should be treated as mouse events in the Unreal Engine’s Slate UI system. This setting is primarily used for input handling and event processing within the Slate framework.
Based on the callsites provided, this setting variable is mainly used in the Slate subsystem, specifically within the FSlateApplication
class. The Slate module is responsible for handling user interface elements and input in Unreal Engine.
The value of this variable is set in the constructor of FSlateApplication
and can be configured through the engine’s configuration files. Specifically, it’s read from the GEngineIni
file under the [MobileSlateUI]
section with the key bTouchFallbackToMouse
.
This variable interacts closely with touch and mouse input events. It’s used in conditional statements to determine whether touch events should be processed as mouse events when they are not handled as touch events.
Developers should be aware that this variable affects how touch input is interpreted on devices that support both touch and mouse input, such as touchscreen laptops or tablets. When set to true, it allows for a more flexible input system that can handle touch input as mouse input when necessary.
Best practices when using this variable include:
-
Consider the target platforms for your application. If you’re developing for both touch and non-touch devices, enabling this option can provide a more consistent input experience.
-
Be mindful of the performance implications. Processing touch events as mouse events may introduce additional overhead, especially on mobile devices.
-
Test thoroughly on various devices to ensure that the input behavior meets your application’s requirements.
-
If you’re developing a mobile-specific UI, you might want to disable this option to ensure touch-specific behaviors are maintained.
-
When modifying this setting, make sure to test all UI interactions to verify that they behave as expected with both touch and mouse inputs.
#Setting Variables
#References In INI files
Location: <Workspace>/Engine/Config/BaseEngine.ini:2940, section: [MobileSlateUI]
- INI Section:
MobileSlateUI
- Raw value:
true
- Is Array:
False
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Slate/Private/Framework/Application/SlateApplication.cpp:811
Scope (from outer to inner):
file
function FSlateApplication::FSlateApplication
Source code excerpt:
, bIsFakingTouched( false )
, bHandleDeviceInputWhenApplicationNotActive(false)
, bTouchFallbackToMouse( true )
, bSoftwareCursorAvailable( false )
, bMenuAnimationsEnabled( false )
, AppIcon(nullptr)
, VirtualDesktopRect( 0,0,0,0 )
, NavigationConfig(MakeShared<FNavigationConfig>())
#if WITH_EDITOR
#Loc: <Workspace>/Engine/Source/Runtime/Slate/Private/Framework/Application/SlateApplication.cpp:835
Scope (from outer to inner):
file
function FSlateApplication::FSlateApplication
Source code excerpt:
if (GConfig)
{
GConfig->GetBool(TEXT("MobileSlateUI"), TEXT("bTouchFallbackToMouse"), bTouchFallbackToMouse, GEngineIni);
GConfig->GetBool(TEXT("CursorControl"), TEXT("bAllowSoftwareCursor"), bSoftwareCursorAvailable, GEngineIni);
}
bRenderOffScreen = FParse::Param(FCommandLine::Get(), TEXT("RenderOffScreen"));
// causes InputCore to initialize, even if statically linked
#Loc: <Workspace>/Engine/Source/Runtime/Slate/Private/Framework/Application/SlateApplication.cpp:5086
Scope (from outer to inner):
file
function bool FSlateApplication::ProcessMouseButtonDownEvent
lambda-function
Source code excerpt:
#endif
}
if ( !Event.IsTouchEvent() || ( !TempReply.IsEventHandled() && this->bTouchFallbackToMouse ) )
{
TempReply = InMouseCaptorWidget.Widget->OnMouseButtonDown(InMouseCaptorWidget.Geometry, Event);
#if WITH_SLATE_DEBUGGING
FSlateDebugging::BroadcastInputEvent(ESlateDebuggingInputEvent::MouseButtonDown, &Event, TempReply, InMouseCaptorWidget.Widget);
#endif
}
#Loc: <Workspace>/Engine/Source/Runtime/Slate/Private/Framework/Application/SlateApplication.cpp:5172
Scope (from outer to inner):
file
lambda-function
Source code excerpt:
#endif
}
if( !Event.IsTouchEvent() || ( !TempReply.IsEventHandled() && this->bTouchFallbackToMouse ) )
{
TempReply = TargetWidget.Widget->OnMouseButtonDown( TargetWidget.Geometry, Event );
#if WITH_SLATE_DEBUGGING
FSlateDebugging::BroadcastInputEvent(ESlateDebuggingInputEvent::MouseButtonDown, &Event, TempReply, TargetWidget.Widget);
#endif
}
#Loc: <Workspace>/Engine/Source/Runtime/Slate/Private/Framework/Application/SlateApplication.cpp:5288
Scope (from outer to inner):
file
lambda-function
Source code excerpt:
}
if (!Event.IsTouchEvent() || (!TempReply.IsEventHandled() && this->bTouchFallbackToMouse))
{
TempReply = TargetWidget.Widget->OnMouseButtonUp( TargetWidget.Geometry, Event );
#if WITH_SLATE_DEBUGGING
FSlateDebugging::BroadcastInputEvent(ESlateDebuggingInputEvent::MouseButtonUp, &Event, TempReply, TargetWidget.Widget);
#endif
}
#Loc: <Workspace>/Engine/Source/Runtime/Slate/Private/Framework/Application/SlateApplication.cpp:5349
Scope (from outer to inner):
file
lambda-function
Source code excerpt:
}
if (!Event.IsTouchEvent() || (!TempReply.IsEventHandled() && bTouchFallbackToMouse))
{
TempReply = CurWidget.Widget->OnMouseButtonUp(CurWidget.Geometry, Event);
#if WITH_SLATE_DEBUGGING
FSlateDebugging::BroadcastInputEvent(ESlateDebuggingInputEvent::MouseButtonUp, &Event, TempReply, CurWidget.Widget);
#endif
}
#Loc: <Workspace>/Engine/Source/Runtime/Slate/Private/Framework/Application/SlateApplication.cpp:5577
Scope (from outer to inner):
file
function bool FSlateApplication::RoutePointerMoveEvent
lambda-function
Source code excerpt:
}
}
if ((!Event.IsTouchEvent() && bAllowMouseFallback) || (!TempReply.IsEventHandled() && this->bTouchFallbackToMouse))
{
// Only handle if not synthetic, else widgets with mouse capture can cause the mouse to move at app start.
if (!bIsSynthetic)
{
TempReply = MouseCaptorWidget.Widget->OnMouseMove(MouseCaptorWidget.Geometry, Event);
}
#Loc: <Workspace>/Engine/Source/Runtime/Slate/Public/Framework/Application/SlateApplication.h:1959
Scope (from outer to inner):
file
class class FSlateApplication : public FSlateApplicationBase , public FGenericApplicationMessageHandler
Source code excerpt:
/** controls whether unhandled touch events fall back to sending mouse events */
bool bTouchFallbackToMouse;
/** .ini controlled option to allow or disallow software cursor rendering */
bool bSoftwareCursorAvailable;
/**
* Slate look and feel