mirror of
https://github.com/ocornut/imgui.git
synced 2026-11-06 06:25:54 +01:00
TextSelect: TextSelectSetCopyShortcut() takes a third optional chord, e.g. Cmd+C, Ctrl+C and Ctrl+Insert with io.ConfigMacOSXBehaviors.
This commit is contained in:
parent
5a512fc607
commit
626b0fbb01
@ -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<int N>
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user