AllowVirtualKeyboard
AllowVirtualKeyboard
#Overview
name: AllowVirtualKeyboard
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Allow the use of a virtual keyboard despite platform main screen being non-touch
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of AllowVirtualKeyboard is to control whether a virtual keyboard can be used on platforms where the main screen is not touch-enabled. This setting is primarily used in the application’s input handling system.
This setting variable is relied upon by the ApplicationCore module, specifically within the GenericPlatformApplicationMisc class. This class is part of the core application functionality in Unreal Engine, handling platform-specific application behaviors.
The value of this variable is set through a console variable (CVar) system. It’s initialized as a static boolean variable bAllowVirtualKeyboard
and then wrapped in an FAutoConsoleVariableRef
named CVarAllowVirtualKeyboard
. This allows the value to be changed at runtime through console commands.
The associated variable bAllowVirtualKeyboard
directly interacts with AllowVirtualKeyboard
. They share the same value, with bAllowVirtualKeyboard
being the actual boolean variable used in the code, while AllowVirtualKeyboard
is the name of the console variable.
Developers must be aware that this variable is marked as read-only (ECVF_ReadOnly
), which means it’s intended to be set early in the application’s lifecycle and not changed frequently during runtime.
When using this variable, developers should consider the following best practices:
- Use it in conjunction with platform-specific checks, as seen in the
RequiresVirtualKeyboard()
function. - Be cautious about changing its value, as it’s marked read-only and might have implications for input handling across the application.
- Consider the performance implications of enabling a virtual keyboard on non-touch platforms.
Regarding the associated variable bAllowVirtualKeyboard
:
- Its purpose is to serve as the actual boolean flag that controls the virtual keyboard allowance.
- It’s used directly in the
RequiresVirtualKeyboard()
function to determine if a virtual keyboard is needed. - The value is set through the console variable system, allowing for potential runtime changes despite being marked as read-only.
- Developers should be aware that modifying this variable directly might not reflect in the console variable system, and vice versa.
- Best practice would be to always use the console variable system to modify this setting, ensuring consistency across the engine.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/ApplicationCore/Private/GenericPlatform/GenericPlatformApplicationMisc.cpp:30
Scope: file
Source code excerpt:
FAutoConsoleVariableRef FGenericPlatformApplicationMisc::CVarAllowVirtualKeyboard(
TEXT("AllowVirtualKeyboard"),
bAllowVirtualKeyboard,
TEXT("Allow the use of a virtual keyboard despite platform main screen being non-touch"),
ECVF_ReadOnly
);
void FGenericPlatformApplicationMisc::PreInit()
#Associated Variable and Callsites
This variable is associated with another variable named bAllowVirtualKeyboard
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/ApplicationCore/Private/GenericPlatform/GenericPlatformApplicationMisc.cpp:27
Scope: file
Source code excerpt:
);
static bool bAllowVirtualKeyboard = false;
FAutoConsoleVariableRef FGenericPlatformApplicationMisc::CVarAllowVirtualKeyboard(
TEXT("AllowVirtualKeyboard"),
bAllowVirtualKeyboard,
TEXT("Allow the use of a virtual keyboard despite platform main screen being non-touch"),
ECVF_ReadOnly
);
void FGenericPlatformApplicationMisc::PreInit()
{
#Loc: <Workspace>/Engine/Source/Runtime/ApplicationCore/Private/GenericPlatform/GenericPlatformApplicationMisc.cpp:93
Scope (from outer to inner):
file
function bool FGenericPlatformApplicationMisc::RequiresVirtualKeyboard
Source code excerpt:
bool FGenericPlatformApplicationMisc::RequiresVirtualKeyboard()
{
return PLATFORM_HAS_TOUCH_MAIN_SCREEN || bAllowVirtualKeyboard;
}
FLinearColor FGenericPlatformApplicationMisc::GetScreenPixelColor(const FVector2D& InScreenPos, float InGamma)
{
return FLinearColor::Black;
}