Fix hierarchy rename field behavior
This commit is contained in:
@@ -354,6 +354,18 @@ inline float InlineRenameFieldRounding() {
|
||||
return 2.0f;
|
||||
}
|
||||
|
||||
inline ImVec4 InlineRenameFieldBackgroundColor() {
|
||||
return ImVec4(0.25f, 0.25f, 0.25f, 1.0f);
|
||||
}
|
||||
|
||||
inline ImVec4 InlineRenameFieldHoveredColor() {
|
||||
return InlineRenameFieldBackgroundColor();
|
||||
}
|
||||
|
||||
inline ImVec4 InlineRenameFieldActiveColor() {
|
||||
return InlineRenameFieldBackgroundColor();
|
||||
}
|
||||
|
||||
inline float InlineRenameFieldHeight() {
|
||||
return ImGui::GetFontSize() + InlineRenameFieldFramePadding().y * 2.0f;
|
||||
}
|
||||
|
||||
@@ -210,6 +210,9 @@ inline InlineRenameFieldResult DrawInlineRenameField(
|
||||
ImGuiInputTextFlags flags = ImGuiInputTextFlags_EnterReturnsTrue | ImGuiInputTextFlags_AutoSelectAll) {
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, InlineRenameFieldFramePadding());
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, InlineRenameFieldRounding());
|
||||
ImGui::PushStyleColor(ImGuiCol_FrameBg, InlineRenameFieldBackgroundColor());
|
||||
ImGui::PushStyleColor(ImGuiCol_FrameBgHovered, InlineRenameFieldHoveredColor());
|
||||
ImGui::PushStyleColor(ImGuiCol_FrameBgActive, InlineRenameFieldActiveColor());
|
||||
ImGui::SetNextItemWidth(width);
|
||||
if (requestFocus) {
|
||||
ImGui::SetKeyboardFocusHere();
|
||||
@@ -219,6 +222,7 @@ inline InlineRenameFieldResult DrawInlineRenameField(
|
||||
const bool active = ImGui::IsItemActive();
|
||||
const bool deactivated = ImGui::IsItemDeactivated();
|
||||
const bool cancelRequested = active && ImGui::IsKeyPressed(ImGuiKey_Escape);
|
||||
ImGui::PopStyleColor(3);
|
||||
ImGui::PopStyleVar(2);
|
||||
|
||||
return InlineRenameFieldResult{ submitted, cancelRequested, deactivated, active };
|
||||
|
||||
Reference in New Issue
Block a user