mirror of
https://github.com/kevinporetti/UnrealImGui.git
synced 2025-01-18 08:20: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.
|
// about dirty parts of keys or mouse buttons arrays.
|
||||||
void ClearUpdateState();
|
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:
|
private:
|
||||||
|
|
||||||
void Reset(bool bKeyboard, bool bMouse);
|
void Reset(bool bKeyboard, bool bMouse);
|
||||||
@ -144,4 +151,6 @@ private:
|
|||||||
bool bIsControlDown = false;
|
bool bIsControlDown = false;
|
||||||
bool bIsShiftDown = false;
|
bool bIsShiftDown = false;
|
||||||
bool bIsAltDown = false;
|
bool bIsAltDown = false;
|
||||||
|
|
||||||
|
bool bKeyboardNavigationEnabled = false;
|
||||||
};
|
};
|
||||||
|
@ -65,8 +65,10 @@ namespace ImGuiInterops
|
|||||||
KeyMap[ImGuiKey_PageDown] = GetKeyIndex(EKeys::PageDown);
|
KeyMap[ImGuiKey_PageDown] = GetKeyIndex(EKeys::PageDown);
|
||||||
KeyMap[ImGuiKey_Home] = GetKeyIndex(EKeys::Home);
|
KeyMap[ImGuiKey_Home] = GetKeyIndex(EKeys::Home);
|
||||||
KeyMap[ImGuiKey_End] = GetKeyIndex(EKeys::End);
|
KeyMap[ImGuiKey_End] = GetKeyIndex(EKeys::End);
|
||||||
|
KeyMap[ImGuiKey_Insert] = GetKeyIndex(EKeys::Insert);
|
||||||
KeyMap[ImGuiKey_Delete] = GetKeyIndex(EKeys::Delete);
|
KeyMap[ImGuiKey_Delete] = GetKeyIndex(EKeys::Delete);
|
||||||
KeyMap[ImGuiKey_Backspace] = GetKeyIndex(EKeys::BackSpace);
|
KeyMap[ImGuiKey_Backspace] = GetKeyIndex(EKeys::BackSpace);
|
||||||
|
KeyMap[ImGuiKey_Space] = GetKeyIndex(EKeys::SpaceBar);
|
||||||
KeyMap[ImGuiKey_Enter] = GetKeyIndex(EKeys::Enter);
|
KeyMap[ImGuiKey_Enter] = GetKeyIndex(EKeys::Enter);
|
||||||
KeyMap[ImGuiKey_Escape] = GetKeyIndex(EKeys::Escape);
|
KeyMap[ImGuiKey_Escape] = GetKeyIndex(EKeys::Escape);
|
||||||
KeyMap[ImGuiKey_A] = GetKeyIndex(EKeys::A);
|
KeyMap[ImGuiKey_A] = GetKeyIndex(EKeys::A);
|
||||||
@ -161,6 +163,12 @@ namespace ImGuiInterops
|
|||||||
// Input State Copying
|
// 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)
|
void CopyInput(ImGuiIO& IO, const FImGuiInputState& InputState)
|
||||||
{
|
{
|
||||||
static const uint32 LeftControl = GetKeyIndex(EKeys::LeftControl);
|
static const uint32 LeftControl = GetKeyIndex(EKeys::LeftControl);
|
||||||
@ -201,5 +209,7 @@ namespace ImGuiInterops
|
|||||||
{
|
{
|
||||||
Copy(InputState.GetCharacters(), IO.InputCharacters);
|
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"),
|
TEXT("1: enabled, input is routed to ImGui and with a few exceptions is consumed"),
|
||||||
ECVF_Default);
|
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,
|
TAutoConsoleVariable<int> DrawMouseCursor(TEXT("ImGui.DrawMouseCursor"), 0,
|
||||||
TEXT("Whether or not mouse cursor in input mode should be drawn by ImGui.\n")
|
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")
|
TEXT("0: disabled, hardware cursor will be used (default)\n")
|
||||||
@ -438,6 +444,8 @@ void SImGuiWidget::UpdateInputEnabled()
|
|||||||
{
|
{
|
||||||
UpdateInputMode(false, IsDirectlyHovered());
|
UpdateInputMode(false, IsDirectlyHovered());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
InputState.SetKeyboardNavigationEnabled(CVars::InputNavigation.GetValueOnGameThread() > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SImGuiWidget::UpdateInputMode(bool bHasKeyboardFocus, bool bHasMousePointer)
|
void SImGuiWidget::UpdateInputMode(bool bHasKeyboardFocus, bool bHasMousePointer)
|
||||||
|
Loading…
Reference in New Issue
Block a user