Merge pull request #214 from ghassanpl/upstream
InputText(): make sure letter-key shortcuts have ONLY the control key pressed
This commit is contained in:
commit
8ac9036db3
11
imgui.cpp
11
imgui.cpp
@ -6525,7 +6525,8 @@ bool ImGui::InputText(const char* label, char* buf, size_t buf_size, ImGuiInputT
|
||||
ImGuiTextEditState& edit_state = g.InputTextState;
|
||||
|
||||
const bool is_ctrl_down = io.KeyCtrl;
|
||||
const bool is_shift_down = io.KeyShift;
|
||||
const bool is_shift_down = io.KeyShift;
|
||||
const bool is_alt_down = io.KeyAlt;
|
||||
const bool focus_requested = window->FocusItemRegister(g.ActiveId == id, (flags & ImGuiInputTextFlags_CallbackCompletion) == 0); // Using completion callback disable keyboard tabbing
|
||||
const bool focus_requested_by_code = focus_requested && (window->FocusIdxAllCounter == window->FocusIdxAllRequestCurrent);
|
||||
const bool focus_requested_by_tab = focus_requested && !focus_requested_by_code;
|
||||
@ -6655,10 +6656,10 @@ bool ImGui::InputText(const char* label, char* buf, size_t buf_size, ImGuiInputT
|
||||
else if (IsKeyPressedMap(ImGuiKey_Backspace)) { edit_state.OnKeyPressed(STB_TEXTEDIT_K_BACKSPACE | k_mask); }
|
||||
else if (IsKeyPressedMap(ImGuiKey_Enter)) { SetActiveId(0); enter_pressed = true; }
|
||||
else if (IsKeyPressedMap(ImGuiKey_Escape)) { SetActiveId(0); cancel_edit = true; }
|
||||
else if (is_ctrl_down && IsKeyPressedMap(ImGuiKey_Z)) { edit_state.OnKeyPressed(STB_TEXTEDIT_K_UNDO); }
|
||||
else if (is_ctrl_down && IsKeyPressedMap(ImGuiKey_Y)) { edit_state.OnKeyPressed(STB_TEXTEDIT_K_REDO); }
|
||||
else if (is_ctrl_down && IsKeyPressedMap(ImGuiKey_A)) { edit_state.SelectAll(); }
|
||||
else if (is_ctrl_down && (IsKeyPressedMap(ImGuiKey_X) || IsKeyPressedMap(ImGuiKey_C)))
|
||||
else if (is_ctrl_down && !is_alt_down && !is_shift_down && IsKeyPressedMap(ImGuiKey_Z)) { edit_state.OnKeyPressed(STB_TEXTEDIT_K_UNDO); }
|
||||
else if (is_ctrl_down && !is_alt_down && !is_shift_down && IsKeyPressedMap(ImGuiKey_Y)) { edit_state.OnKeyPressed(STB_TEXTEDIT_K_REDO); }
|
||||
else if (is_ctrl_down && !is_alt_down && !is_shift_down && IsKeyPressedMap(ImGuiKey_A)) { edit_state.SelectAll(); }
|
||||
else if (is_ctrl_down && !is_alt_down && !is_shift_down && (IsKeyPressedMap(ImGuiKey_X) || IsKeyPressedMap(ImGuiKey_C)))
|
||||
{
|
||||
// Cut, Copy
|
||||
const bool cut = IsKeyPressedMap(ImGuiKey_X);
|
||||
|
Loading…
Reference in New Issue
Block a user