diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index f5aa55d7f29c..0fa58d874ffb 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -43,6 +43,8 @@ Other Changes: Enter keep the input active and select all text. - Nav: Fixed moving/resizing window with gamepad or keyboard when running at very high framerate. - Misc: io.Framerate moving average now converge in 60 frames instead of 120. (#5236, #4138) +- Tools: Item Picker: Mouse button can be changed by holding Ctrl+Shift, making it easier + to use the Item Picker in e.g. menus. (#2673) - Backends: Metal: Use __bridge for ARC based systems. (#5403) [@stack] - Backends: Metal: Add dispatch synchronization. (#5447) [@luigifcruz] - Backends: OSX: Fixes to support full app creation in C++. (#5403) [@stack] diff --git a/imgui.cpp b/imgui.cpp index 8f637e432a14..ff2b92731ead 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -13229,16 +13229,24 @@ void ImGui::UpdateDebugToolItemPicker() SetMouseCursor(ImGuiMouseCursor_Hand); if (IsKeyPressed(ImGuiKey_Escape)) g.DebugItemPickerActive = false; - if (IsMouseClicked(0) && hovered_id) + const bool change_mapping = g.IO.KeyMods == (ImGuiModFlags_Ctrl | ImGuiModFlags_Shift); + if (!change_mapping && IsMouseClicked(g.DebugItemPickerMouseButton) && hovered_id) { g.DebugItemPickerBreakId = hovered_id; g.DebugItemPickerActive = false; } - SetNextWindowBgAlpha(0.60f); + for (int mouse_button = 0; mouse_button < 3; mouse_button++) + if (change_mapping && IsMouseClicked(mouse_button)) + g.DebugItemPickerMouseButton = (ImU8)mouse_button; + SetNextWindowBgAlpha(0.70f); BeginTooltip(); Text("HoveredId: 0x%08X", hovered_id); Text("Press ESC to abort picking."); - TextColored(GetStyleColorVec4(hovered_id ? ImGuiCol_Text : ImGuiCol_TextDisabled), "Click to break in debugger!"); + const char* mouse_button_names[] = { "Left", "Right", "Middle" }; + if (change_mapping) + Text("Remap w/ Ctrl+Shift: click anywhere to select new mouse button."); + else + TextColored(GetStyleColorVec4(hovered_id ? ImGuiCol_Text : ImGuiCol_TextDisabled), "Click %s Button to break in debugger! (remap w/ Ctrl+Shift)", mouse_button_names[g.DebugItemPickerMouseButton]); EndTooltip(); } diff --git a/imgui_demo.cpp b/imgui_demo.cpp index 462e07e83830..e307aa79411a 100644 --- a/imgui_demo.cpp +++ b/imgui_demo.cpp @@ -7805,7 +7805,8 @@ void ShowExampleAppDocuments(bool* p_open) if (ImGui::MenuItem("Close All Documents", NULL, false, open_count > 0)) for (int doc_n = 0; doc_n < app.Documents.Size; doc_n++) app.Documents[doc_n].DoQueueClose(); - if (ImGui::MenuItem("Exit", "Alt+F4")) {} + if (ImGui::MenuItem("Exit", "Ctrl+F4") && p_open) + *p_open = false; ImGui::EndMenu(); } ImGui::EndMenuBar(); diff --git a/imgui_internal.h b/imgui_internal.h index a2739f939a02..4419e29fba97 100644 --- a/imgui_internal.h +++ b/imgui_internal.h @@ -1822,6 +1822,7 @@ struct ImGuiContext ImGuiDebugLogFlags DebugLogFlags; ImGuiTextBuffer DebugLogBuf; bool DebugItemPickerActive; // Item picker is active (started with DebugStartItemPicker()) + ImU8 DebugItemPickerMouseButton; ImGuiID DebugItemPickerBreakId; // Will call IM_DEBUG_BREAK() when encountering this ID ImGuiMetricsConfig DebugMetricsConfig; ImGuiStackTool DebugStackTool; @@ -1979,6 +1980,7 @@ struct ImGuiContext DebugLogFlags = ImGuiDebugLogFlags_OutputToTTY; DebugItemPickerActive = false; + DebugItemPickerMouseButton = ImGuiMouseButton_Left; DebugItemPickerBreakId = 0; memset(FramerateSecPerFrame, 0, sizeof(FramerateSecPerFrame));