mirror of
https://github.com/Drezil/imgui.git
synced 2024-12-18 06:06:35 +00:00
add shortcut+backspace support
This commit is contained in:
parent
86f42b5950
commit
921fc50c85
11
imgui.cpp
11
imgui.cpp
@ -7759,6 +7759,7 @@ bool ImGui::InputTextEx(const char* label, char* buf, int buf_size, const ImVec2
|
||||
bool cancel_edit = false;
|
||||
const int k_mask = (is_shift_down ? STB_TEXTEDIT_K_SHIFT : 0);
|
||||
const bool is_shortcutkey_only = (io.ShortcutsUseSuperKey ? (is_super_down && !is_alt_down && !is_shift_down && !is_ctrl_down) : (is_ctrl_down && !is_alt_down && !is_shift_down && !is_super_down));
|
||||
const bool is_shortcutkey_and_maybe_shift_only = (io.ShortcutsUseSuperKey ? (is_super_down && !is_alt_down && !is_ctrl_down) : (is_ctrl_down && !is_alt_down && !is_super_down));
|
||||
const bool is_wordmove_key_down = (io.WordMovementUsesAltKey ? io.KeyAlt : io.KeyCtrl);
|
||||
const bool is_line_startend_key_down = io.HomeEndUsesArrowSuperKey && is_super_down && !is_ctrl_down && !is_alt_down;
|
||||
const bool is_text_startend_key_down = is_line_startend_key_down;
|
||||
@ -7770,7 +7771,15 @@ bool ImGui::InputTextEx(const char* label, char* buf, int buf_size, const ImVec2
|
||||
else if (IsKeyPressedMap(ImGuiKey_Home)) { edit_state.OnKeyPressed(is_ctrl_down ? STB_TEXTEDIT_K_TEXTSTART | k_mask : STB_TEXTEDIT_K_LINESTART | k_mask); }
|
||||
else if (IsKeyPressedMap(ImGuiKey_End)) { edit_state.OnKeyPressed(is_ctrl_down ? STB_TEXTEDIT_K_TEXTEND | k_mask : STB_TEXTEDIT_K_LINEEND | k_mask); }
|
||||
else if (IsKeyPressedMap(ImGuiKey_Delete) && is_editable) { edit_state.OnKeyPressed(STB_TEXTEDIT_K_DELETE | k_mask); }
|
||||
else if (IsKeyPressedMap(ImGuiKey_Backspace) && is_editable) { if (is_ctrl_down && !edit_state.HasSelection()) edit_state.OnKeyPressed(STB_TEXTEDIT_K_WORDLEFT|STB_TEXTEDIT_K_SHIFT); edit_state.OnKeyPressed(STB_TEXTEDIT_K_BACKSPACE | k_mask); }
|
||||
else if (IsKeyPressedMap(ImGuiKey_Backspace) && is_editable)
|
||||
{
|
||||
if (!edit_state.HasSelection())
|
||||
{
|
||||
if (is_wordmove_key_down) edit_state.OnKeyPressed(STB_TEXTEDIT_K_WORDLEFT|STB_TEXTEDIT_K_SHIFT);
|
||||
else if (io.ShortcutsUseSuperKey && is_shortcutkey_and_maybe_shift_only) edit_state.OnKeyPressed(STB_TEXTEDIT_K_LINESTART|STB_TEXTEDIT_K_SHIFT);
|
||||
}
|
||||
edit_state.OnKeyPressed(STB_TEXTEDIT_K_BACKSPACE | k_mask);
|
||||
}
|
||||
else if (IsKeyPressedMap(ImGuiKey_Enter))
|
||||
{
|
||||
bool ctrl_enter_for_new_line = (flags & ImGuiInputTextFlags_CtrlEnterForNewLine) != 0;
|
||||
|
Loading…
Reference in New Issue
Block a user