mirror of
https://github.com/kevinporetti/UnrealImGui.git
synced 2025-01-18 00:10:32 +00:00
Enabled experimental ImGui keyboard navigation feature.
This commit is contained in:
parent
413b4f407a
commit
e83f37d518
@ -117,6 +117,13 @@ public:
|
||||
// about dirty parts of keys or mouse buttons arrays.
|
||||
void ClearUpdateState();
|
||||
|
||||
// Check whether keyboard navigation is enabled.
|
||||
bool IsKeyboardNavigationEnabled() const { return bKeyboardNavigationEnabled; }
|
||||
|
||||
// Set whether keyboard navigation is enabled.
|
||||
// @param bEnabled - True, if navigation is enabled
|
||||
void SetKeyboardNavigationEnabled(bool bEnabled) { bKeyboardNavigationEnabled = bEnabled; }
|
||||
|
||||
private:
|
||||
|
||||
void Reset(bool bKeyboard, bool bMouse);
|
||||
@ -144,4 +151,6 @@ private:
|
||||
bool bIsControlDown = false;
|
||||
bool bIsShiftDown = false;
|
||||
bool bIsAltDown = false;
|
||||
|
||||
bool bKeyboardNavigationEnabled = false;
|
||||
};
|
||||
|
@ -65,8 +65,10 @@ namespace ImGuiInterops
|
||||
KeyMap[ImGuiKey_PageDown] = GetKeyIndex(EKeys::PageDown);
|
||||
KeyMap[ImGuiKey_Home] = GetKeyIndex(EKeys::Home);
|
||||
KeyMap[ImGuiKey_End] = GetKeyIndex(EKeys::End);
|
||||
KeyMap[ImGuiKey_Insert] = GetKeyIndex(EKeys::Insert);
|
||||
KeyMap[ImGuiKey_Delete] = GetKeyIndex(EKeys::Delete);
|
||||
KeyMap[ImGuiKey_Backspace] = GetKeyIndex(EKeys::BackSpace);
|
||||
KeyMap[ImGuiKey_Space] = GetKeyIndex(EKeys::SpaceBar);
|
||||
KeyMap[ImGuiKey_Enter] = GetKeyIndex(EKeys::Enter);
|
||||
KeyMap[ImGuiKey_Escape] = GetKeyIndex(EKeys::Escape);
|
||||
KeyMap[ImGuiKey_A] = GetKeyIndex(EKeys::A);
|
||||
@ -161,6 +163,12 @@ namespace ImGuiInterops
|
||||
// Input State Copying
|
||||
//====================================================================================================
|
||||
|
||||
template<typename TFlags, typename TFlag>
|
||||
static inline constexpr void SetFlag(TFlags& Flags, TFlag Flag, bool bSet)
|
||||
{
|
||||
Flags = bSet ? Flags | Flag : Flags & ~Flag;
|
||||
}
|
||||
|
||||
void CopyInput(ImGuiIO& IO, const FImGuiInputState& InputState)
|
||||
{
|
||||
static const uint32 LeftControl = GetKeyIndex(EKeys::LeftControl);
|
||||
@ -201,5 +209,7 @@ namespace ImGuiInterops
|
||||
{
|
||||
Copy(InputState.GetCharacters(), IO.InputCharacters);
|
||||
}
|
||||
|
||||
SetFlag(IO.ConfigFlags, ImGuiConfigFlags_NavEnableKeyboard, InputState.IsKeyboardNavigationEnabled());
|
||||
}
|
||||
}
|
||||
|
@ -51,6 +51,12 @@ namespace CVars
|
||||
TEXT("1: enabled, input is routed to ImGui and with a few exceptions is consumed"),
|
||||
ECVF_Default);
|
||||
|
||||
TAutoConsoleVariable<int> InputNavigation(TEXT("ImGui.InputNavigation"), 0,
|
||||
TEXT("[EXPERIMENTAL, WIP] Set ImGui navigation mode.\n")
|
||||
TEXT("0: navigation is disabled\n")
|
||||
TEXT("1: keyboard navigation"),
|
||||
ECVF_Default);
|
||||
|
||||
TAutoConsoleVariable<int> DrawMouseCursor(TEXT("ImGui.DrawMouseCursor"), 0,
|
||||
TEXT("Whether or not mouse cursor in input mode should be drawn by ImGui.\n")
|
||||
TEXT("0: disabled, hardware cursor will be used (default)\n")
|
||||
@ -438,6 +444,8 @@ void SImGuiWidget::UpdateInputEnabled()
|
||||
{
|
||||
UpdateInputMode(false, IsDirectlyHovered());
|
||||
}
|
||||
|
||||
InputState.SetKeyboardNavigationEnabled(CVars::InputNavigation.GetValueOnGameThread() > 0);
|
||||
}
|
||||
|
||||
void SImGuiWidget::UpdateInputMode(bool bHasKeyboardFocus, bool bHasMousePointer)
|
||||
|
Loading…
Reference in New Issue
Block a user