RenderFocusRule
RenderFocusRule
#Overview
name: RenderFocusRule
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 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of RenderFocusRule is to control when and how focus is rendered in the user interface of an Unreal Engine game. It is used to determine under what circumstances the focus indicator should be displayed on UI elements.
This setting variable is primarily used by the Engine module, specifically within the user interface and game viewport systems. It is defined in the UUserInterfaceSettings class, which is part of the Engine’s UI configuration system.
The value of this variable is set in the constructor of UUserInterfaceSettings, where it is initialized to ERenderFocusRule::NavigationOnly by default. It can be modified through the project settings in the Unreal Editor or programmatically.
RenderFocusRule interacts with the EFocusCause enum, which determines the cause of focus change (e.g., mouse interaction, navigation). This interaction is evident in the QueryShowFocus function of UGameViewportClient.
Developers must be aware that this variable affects the visibility of focus indicators across the entire game UI. It can impact the user experience, especially for players using different input methods (keyboard, gamepad, mouse).
Best practices when using this variable include:
- Consider accessibility needs when setting the rule, ensuring that focus is clear for users relying on keyboard navigation.
- Test the UI with different input methods to ensure the chosen rule works well for all intended interaction types.
- Be consistent with the focus rendering rule throughout the game to maintain a coherent user experience.
- If modifying programmatically, ensure changes are made at appropriate times, such as during game initialization or when changing UI modes.
#Setting Variables
#References In INI files
Location: <Workspace>/Projects/Lyra/Config/DefaultEngine.ini:234, section: [/Script/Engine.UserInterfaceSettings]
- INI Section:
/Script/Engine.UserInterfaceSettings
- Raw value:
Never
- Is Array:
False
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Classes/Engine/UserInterfaceSettings.h:124
Scope (from outer to inner):
file
class class UUserInterfaceSettings : public UDeveloperSettings
Source code excerpt:
*/
UPROPERTY(config, EditAnywhere, Category = "Focus")
ERenderFocusRule RenderFocusRule;
UPROPERTY(config, EditAnywhere, Category = "Hardware Cursors")
TMap<TEnumAsByte<EMouseCursor::Type>, FHardwareCursorReference> HardwareCursors;
UPROPERTY(config, EditAnywhere, Category = "Software Cursors", meta = ( MetaClass = "/Script/UMG.UserWidget" ))
TMap<TEnumAsByte<EMouseCursor::Type>, FSoftClassPath> SoftwareCursors;
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/GameViewportClient.cpp:2235
Scope (from outer to inner):
file
function TOptional<bool> UGameViewportClient::QueryShowFocus
Source code excerpt:
UUserInterfaceSettings* UISettings = GetMutableDefault<UUserInterfaceSettings>(UUserInterfaceSettings::StaticClass());
if ( UISettings->RenderFocusRule == ERenderFocusRule::Never ||
(UISettings->RenderFocusRule == ERenderFocusRule::NonPointer && InFocusCause == EFocusCause::Mouse) ||
(UISettings->RenderFocusRule == ERenderFocusRule::NavigationOnly && InFocusCause != EFocusCause::Navigation))
{
return false;
}
return true;
}
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/UserInterfaceSettings.cpp:12
Scope (from outer to inner):
file
function UUserInterfaceSettings::UUserInterfaceSettings
Source code excerpt:
UUserInterfaceSettings::UUserInterfaceSettings(const FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer)
, RenderFocusRule(ERenderFocusRule::NavigationOnly)
, ApplicationScale(1)
, bLoadWidgetsOnDedicatedServer(true)
, bAuthorizeAutomaticWidgetVariableCreation(true)
#if WITH_EDITORONLY_DATA
, CustomFontDPI(FontConstants::RenderDPI)
, FontDPIPreset(ConvertToEFontDPI(CustomFontDPI))