diff --git a/misc/text_select/imgui_text_select.cpp b/misc/text_select/imgui_text_select.cpp index 4f2f7d4a5..cdd6849b5 100644 --- a/misc/text_select/imgui_text_select.cpp +++ b/misc/text_select/imgui_text_select.cpp @@ -56,7 +56,7 @@ struct ImGuiTextSelectState ImGuiTextSelectCopyFeedbackCallback CopyFeedback = NULL; void* CopyFeedbackUserData = NULL; ImGuiKeyChord SelectAllChords[2] = { ImGuiMod_Ctrl | ImGuiKey_A, 0 }; - ImGuiKeyChord CopyChords[2] = { ImGuiMod_Ctrl | ImGuiKey_C, ImGuiMod_Ctrl | ImGuiKey_Insert }; + ImGuiKeyChord CopyChords[3] = { ImGuiMod_Ctrl | ImGuiKey_C, ImGuiMod_Ctrl | ImGuiKey_Insert, 0 }; double FlashStartTime = -1.0; // Built-in copy feedback: the highlight turns opaque and fades back bool Delimiters[128] = {}; @@ -887,7 +887,8 @@ static void TextSelectSelectAllInContainer(ImGuiTextSelectState* st) st->Block = false; } -static ImGuiKey TextSelectChordPressed(const ImGuiKeyChord (&chords)[2]) +template +static ImGuiKey TextSelectChordPressed(const ImGuiKeyChord (&chords)[N]) { for (ImGuiKeyChord chord : chords) if (chord != 0 && ImGui::IsKeyChordPressed(chord)) @@ -1279,12 +1280,13 @@ void ImGui::TextSelectSetCopyFeedbackCallback(ImGuiTextSelectCopyFeedbackCallbac } } -void ImGui::TextSelectSetCopyShortcut(ImGuiKeyChord key_chord, ImGuiKeyChord alt_key_chord) +void ImGui::TextSelectSetCopyShortcut(ImGuiKeyChord key_chord, ImGuiKeyChord alt_key_chord, ImGuiKeyChord alt_key_chord2) { if (ImGuiTextSelectState* st = TextSelectGetState()) { st->CopyChords[0] = key_chord; st->CopyChords[1] = alt_key_chord; + st->CopyChords[2] = alt_key_chord2; } } diff --git a/misc/text_select/imgui_text_select.h b/misc/text_select/imgui_text_select.h index 587de6fbf..cd238c3d0 100644 --- a/misc/text_select/imgui_text_select.h +++ b/misc/text_select/imgui_text_select.h @@ -61,10 +61,12 @@ namespace ImGui void TextSelectSetCopyFeedbackCallback(ImGuiTextSelectCopyFeedbackCallback callback, void* user_data); // ASCII characters that end a word, besides blanks. Other characters, including all non-ASCII, are word characters. void TextSelectSetWordDelimiters(const char* delimiters); + // Default ImGuiMod_Ctrl | ImGuiKey_C and ImGuiMod_Ctrl | ImGuiKey_Insert. Any chord copies; 0 disables it. With + // io.ConfigMacOSXBehaviors ImGuiMod_Ctrl is Cmd and ImGuiMod_Super is Ctrl, so the Ctrl+Insert key is + // ImGuiMod_Super | ImGuiKey_Insert there. + void TextSelectSetCopyShortcut(ImGuiKeyChord key_chord, ImGuiKeyChord alt_key_chord = 0, ImGuiKeyChord alt_key_chord2 = 0); // Default ImGuiMod_Ctrl | ImGuiKey_A (Cmd+A on macOS with io.ConfigMacOSXBehaviors). Either chord selects; 0 disables // it, e.g. (ImGuiMod_Ctrl | ImGuiKey_A, ImGuiMod_Super | ImGuiKey_A) also accepts the other modifier. - // Default ImGuiMod_Ctrl | ImGuiKey_C and ImGuiMod_Ctrl | ImGuiKey_Insert. Either chord copies; 0 disables it. - void TextSelectSetCopyShortcut(ImGuiKeyChord key_chord, ImGuiKeyChord alt_key_chord = 0); void TextSelectSetSelectAllShortcut(ImGuiKeyChord key_chord, ImGuiKeyChord alt_key_chord = 0); // Text drawn in between is ignored (as ImGuiItemFlags_NoTextSelect), and clicks on that stretch of the current