Slate.EnableSyntheticCursorMoves

Slate.EnableSyntheticCursorMoves

#Overview

name: Slate.EnableSyntheticCursorMoves

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

It is referenced in 3 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of Slate.EnableSyntheticCursorMoves is to control the generation of synthetic cursor move events in the Slate UI framework. This setting is primarily used in the Slate subsystem of Unreal Engine, which is responsible for handling user interface elements and interactions.

The Slate subsystem relies on this setting variable to determine whether synthetic cursor moves should be generated. It’s used in the SlateUser.cpp file, which is part of the Slate runtime module.

The value of this variable is set using an FAutoConsoleVariableRef, which allows it to be modified at runtime through console commands. By default, it’s set to true.

This variable interacts directly with its associated boolean variable bEnableSyntheticCursorMoves. They share the same value, and bEnableSyntheticCursorMoves is used in the actual code logic.

Developers must be aware that this variable affects the behavior of cursor movement in the Slate UI. When enabled, it allows the UI to update even when the mouse isn’t moving, which can be crucial for certain UI interactions and updates.

Best practices when using this variable include:

  1. Only disable it if you have a specific reason to do so, as it may affect UI responsiveness.
  2. If you need to modify it at runtime, use the appropriate console command.
  3. Be aware of its impact on UI behavior, especially in situations where you’re dealing with cursor interactions or UI updates.

Regarding the associated variable bEnableSyntheticCursorMoves:

The purpose of bEnableSyntheticCursorMoves is to act as the actual boolean flag used in the code logic to determine if synthetic cursor moves should be generated.

This variable is used directly in the Slate subsystem, specifically in the FSlateUser class within the SlateUser.cpp file.

Its value is set by the Slate.EnableSyntheticCursorMoves console variable through the FAutoConsoleVariableRef mechanism.

It interacts directly with the Slate.EnableSyntheticCursorMoves console variable, sharing the same value.

Developers should be aware that this is the actual variable checked in the code logic (e.g., in the SynthesizeCursorMoveIfNeeded function) to determine if synthetic cursor moves should be generated.

Best practices for this variable include:

  1. Treat it as read-only in most cases, as its value is controlled by the console variable.
  2. If you need to modify its behavior, use the Slate.EnableSyntheticCursorMoves console variable instead of directly modifying bEnableSyntheticCursorMoves.
  3. Be aware of its usage in performance-critical sections, as it’s checked in what appears to be a frequently called function (SynthesizeCursorMoveIfNeeded).

#References in C++ code

#Callsites

This variable is referenced in the following C++ source code:

#Loc: <Workspace>/Engine/Source/Runtime/Slate/Private/Framework/Application/SlateUser.cpp:27

Scope: file

Source code excerpt:

static bool bEnableSyntheticCursorMoves = true;
FAutoConsoleVariableRef CVarEnableSyntheticCursorMoves(
	TEXT("Slate.EnableSyntheticCursorMoves"),
	bEnableSyntheticCursorMoves,
	TEXT("")
);

static bool bEnableCursorQueries = true;
FAutoConsoleVariableRef CVarEnableCursorQueries(

#Associated Variable and Callsites

This variable is associated with another variable named bEnableSyntheticCursorMoves. They share the same value. See the following C++ source code.

#Loc: <Workspace>/Engine/Source/Runtime/Slate/Private/Framework/Application/SlateUser.cpp:25

Scope: file

Source code excerpt:

}

static bool bEnableSyntheticCursorMoves = true;
FAutoConsoleVariableRef CVarEnableSyntheticCursorMoves(
	TEXT("Slate.EnableSyntheticCursorMoves"),
	bEnableSyntheticCursorMoves,
	TEXT("")
);

static bool bEnableCursorQueries = true;
FAutoConsoleVariableRef CVarEnableCursorQueries(
	TEXT("Slate.EnableCursorQueries"),

#Loc: <Workspace>/Engine/Source/Runtime/Slate/Private/Framework/Application/SlateUser.cpp:672

Scope (from outer to inner):

file
function     bool FSlateUser::SynthesizeCursorMoveIfNeeded

Source code excerpt:

{
	// The slate loading widget thread is not allowed to execute this code as it is unsafe to read the hittest grid in another thread
	if (bEnableSyntheticCursorMoves && IsInGameThread() && ensure(Cursor) && --NumPendingSyntheticCursorMoves >= 0)
	{
		// Synthetic cursor/mouse events accomplish two goals:
		// 1) The UI can change even if the mouse doesn't move.
		//    Synthesizing a mouse move sends out events.
		//    In this case, the current and previous position will be the same.
		//