mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-23 12:27:01 +00:00
BeginCombo() tweaks, merged from Navigation branch.
This commit is contained in:
parent
9e2f202f05
commit
51fcef0c21
31
imgui.cpp
31
imgui.cpp
@ -7020,7 +7020,7 @@ bool ImGui::DragFloat(const char* label, float* v, float v_speed, float v_min, f
|
|||||||
// Tabbing or CTRL-clicking on Drag turns it into an input box
|
// Tabbing or CTRL-clicking on Drag turns it into an input box
|
||||||
bool start_text_input = false;
|
bool start_text_input = false;
|
||||||
const bool tab_focus_requested = FocusableItemRegister(window, id);
|
const bool tab_focus_requested = FocusableItemRegister(window, id);
|
||||||
if (tab_focus_requested || (hovered && (g.IO.MouseClicked[0] | g.IO.MouseDoubleClicked[0])))
|
if (tab_focus_requested || (hovered && (g.IO.MouseClicked[0] || g.IO.MouseDoubleClicked[0])))
|
||||||
{
|
{
|
||||||
SetActiveID(id, window);
|
SetActiveID(id, window);
|
||||||
FocusWindow(window);
|
FocusWindow(window);
|
||||||
@ -8599,25 +8599,31 @@ bool ImGui::BeginCombo(const char* label, const char* preview_value, float popup
|
|||||||
if (label_size.x > 0)
|
if (label_size.x > 0)
|
||||||
RenderText(ImVec2(frame_bb.Max.x + style.ItemInnerSpacing.x, frame_bb.Min.y + style.FramePadding.y), label);
|
RenderText(ImVec2(frame_bb.Max.x + style.ItemInnerSpacing.x, frame_bb.Min.y + style.FramePadding.y), label);
|
||||||
|
|
||||||
|
bool popup_toggled = false;
|
||||||
if (hovered)
|
if (hovered)
|
||||||
{
|
{
|
||||||
SetHoveredID(id);
|
SetHoveredID(id);
|
||||||
if (g.IO.MouseClicked[0])
|
if (g.IO.MouseClicked[0])
|
||||||
{
|
{
|
||||||
ClearActiveID();
|
ClearActiveID();
|
||||||
if (IsPopupOpen(id))
|
popup_toggled = true;
|
||||||
{
|
|
||||||
ClosePopup(id);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
FocusWindow(window);
|
|
||||||
OpenPopup(label);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (popup_toggled)
|
||||||
|
{
|
||||||
|
if (popup_open)
|
||||||
|
{
|
||||||
|
ClosePopup(id);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
FocusWindow(window);
|
||||||
|
OpenPopupEx(id, false);
|
||||||
|
}
|
||||||
|
popup_open = !popup_open;
|
||||||
|
}
|
||||||
|
|
||||||
if (!IsPopupOpen(id))
|
if (!popup_open)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
float popup_y1 = frame_bb.Max.y;
|
float popup_y1 = frame_bb.Max.y;
|
||||||
@ -9054,7 +9060,10 @@ bool ImGui::BeginMenu(const char* label, bool enabled)
|
|||||||
want_open = menu_is_open = false;
|
want_open = menu_is_open = false;
|
||||||
}
|
}
|
||||||
else if (pressed || (hovered && menuset_is_open && !menu_is_open)) // menu-bar: first click to open, then hover to open others
|
else if (pressed || (hovered && menuset_is_open && !menu_is_open)) // menu-bar: first click to open, then hover to open others
|
||||||
|
{
|
||||||
want_open = true;
|
want_open = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (!enabled) // explicitly close if an open menu becomes disabled, facilitate users code a lot in pattern such as 'if (BeginMenu("options", has_object)) { ..use object.. }'
|
if (!enabled) // explicitly close if an open menu becomes disabled, facilitate users code a lot in pattern such as 'if (BeginMenu("options", has_object)) { ..use object.. }'
|
||||||
want_close = true;
|
want_close = true;
|
||||||
if (want_close && IsPopupOpen(id))
|
if (want_close && IsPopupOpen(id))
|
||||||
|
Loading…
Reference in New Issue
Block a user