CommonButton.EnableSimulateHoverOnTouch
CommonButton.EnableSimulateHoverOnTouch
#Overview
name: CommonButton.EnableSimulateHoverOnTouch
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Allows buttons to simulate hovering on touch in accordance with the property SimulateHoverOnTouchInput.\n0: Disable, 1: Enable (default)
It is referenced in 4
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of CommonButton.EnableSimulateHoverOnTouch is to control whether buttons can simulate hovering behavior on touch input devices. This setting is primarily used in the CommonUI plugin, which is part of the Unreal Engine’s UI system.
This setting variable is relied upon by the CommonUI plugin, specifically within the CommonButtonBase class. It’s used to enhance the user interaction experience on touch-based devices by simulating hover effects typically associated with mouse input.
The value of this variable is set using a console variable (CVar) system. It’s initialized to 1 (enabled) by default but can be changed at runtime through console commands or programmatically.
The associated variable bEnableSimulateHoverOnTouchInput interacts directly with CommonButton.EnableSimulateHoverOnTouch. They share the same value, with bEnableSimulateHoverOnTouchInput being the actual boolean flag used in the code logic.
Developers must be aware that this setting affects the behavior of buttons on touch devices. When enabled, it allows buttons to simulate hover states even on devices that don’t typically support hover interactions. This can change the feel of the UI and may impact user experience.
Best practices when using this variable include:
- Consider the target platforms for your game. If you’re developing primarily for touch devices, you might want to keep this enabled for a more responsive UI.
- Test your UI thoroughly with this setting both enabled and disabled to ensure your interface works well in both scenarios.
- Be consistent in its usage across your entire UI to maintain a uniform user experience.
Regarding the associated variable bEnableSimulateHoverOnTouchInput:
- Its purpose is to act as the actual flag checked in the code to determine whether hover simulation should occur on touch input.
- It’s used within the CommonButtonBase class, specifically in the HandleButtonPressed and HandleButtonReleased methods.
- Its value is set by the CommonButton.EnableSimulateHoverOnTouch CVar.
- It interacts with other variables like bSimulateHoverOnTouchInput (a property of the button) and the current input type from the CommonInputSubsystem.
- Developers should be aware that this variable’s state affects the button’s behavior only when the current input type is Touch.
- Best practices include ensuring that the bSimulateHoverOnTouchInput property on individual buttons is set appropriately to work in conjunction with this global setting.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Plugins/Runtime/CommonUI/Source/CommonUI/Private/CommonButtonBase.cpp:34
Scope (from outer to inner):
file
namespace UE::CommonUI::Private
Source code excerpt:
int32 bEnableSimulateHoverOnTouchInput = 1;
FAutoConsoleVariableRef CVarEnableSimulateHoverOnTouchInput(
TEXT("CommonButton.EnableSimulateHoverOnTouch"),
bEnableSimulateHoverOnTouchInput,
TEXT("Allows buttons to simulate hovering on touch in accordance with the property SimulateHoverOnTouchInput.\n0: Disable, 1: Enable (default)"),
ECVF_Default);
}
//////////////////////////////////////////////////////////////////////////
#Associated Variable and Callsites
This variable is associated with another variable named bEnableSimulateHoverOnTouchInput
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Plugins/Runtime/CommonUI/Source/CommonUI/Private/CommonButtonBase.cpp:32
Scope (from outer to inner):
file
namespace UE::CommonUI::Private
Source code excerpt:
namespace UE::CommonUI::Private
{
int32 bEnableSimulateHoverOnTouchInput = 1;
FAutoConsoleVariableRef CVarEnableSimulateHoverOnTouchInput(
TEXT("CommonButton.EnableSimulateHoverOnTouch"),
bEnableSimulateHoverOnTouchInput,
TEXT("Allows buttons to simulate hovering on touch in accordance with the property SimulateHoverOnTouchInput.\n0: Disable, 1: Enable (default)"),
ECVF_Default);
}
//////////////////////////////////////////////////////////////////////////
// UCommonButtonStyle
#Loc: <Workspace>/Engine/Plugins/Runtime/CommonUI/Source/CommonUI/Private/CommonButtonBase.cpp:1353
Scope (from outer to inner):
file
function void UCommonButtonBase::HandleButtonPressed
Source code excerpt:
UCommonInputSubsystem* CommonInputSubsystem = GetInputSubsystem();
if (CommonInputSubsystem && CommonInputSubsystem->GetCurrentInputType() == ECommonInputType::Touch && bSimulateHoverOnTouchInput && UE::CommonUI::Private::bEnableSimulateHoverOnTouchInput)
{
// Simulate hover events when using touch input
NativeOnHovered();
}
if (bRequiresHold && HoldTime > 0.f)
#Loc: <Workspace>/Engine/Plugins/Runtime/CommonUI/Source/CommonUI/Private/CommonButtonBase.cpp:1381
Scope (from outer to inner):
file
function void UCommonButtonBase::HandleButtonReleased
Source code excerpt:
UCommonInputSubsystem* CommonInputSubsystem = GetInputSubsystem();
if (CommonInputSubsystem && CommonInputSubsystem->GetCurrentInputType() == ECommonInputType::Touch && bSimulateHoverOnTouchInput && UE::CommonUI::Private::bEnableSimulateHoverOnTouchInput)
{
// Simulate hover events when using touch input
NativeOnUnhovered();
}
if (bRequiresHold && HoldTime > 0.f)