CommonButton.EnableSimulateHoverOnTouch

CommonButton.EnableSimulateHoverOnTouch

#Overview

name: CommonButton.EnableSimulateHoverOnTouch

This variable is created as a Console Variable (cvar).

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:

  1. 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.
  2. Test your UI thoroughly with this setting both enabled and disabled to ensure your interface works well in both scenarios.
  3. Be consistent in its usage across your entire UI to maintain a uniform user experience.

Regarding the associated variable bEnableSimulateHoverOnTouchInput:

#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)