Skip to content

Commit f4ef420

Browse files
AJ Weeksocornut
authored andcommitted
InputText: Added support for Ctrl+Delete to delete up to end of word. (#6067)
1 parent 0749061 commit f4ef420

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

docs/CHANGELOG.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ All changes:
4747
is scaled. Scaling wasn't taken into account, leading to ellipsis character straying
4848
slightly out of its expected boundaries. (#2775)
4949
- Text: Tweaked rendering of three-dots "..." ellipsis variant. (#2775, #4269)
50+
- InputText: Added support for Ctrl+Delete to delete up to end-of-word. (#6067) [@ajweeks]
51+
(Not adding Super+Delete to delete to up to end-of-line on OSX, as OSX doesn't have it)
5052
- Menus: Fixed layout of MenuItem()/BeginMenu() when label contains a '\n'. (#6116) [@imkcy9]
5153
- PlotHistogram, PlotLines: Passing negative sizes honor alignment like other widgets.
5254
- ImDrawList: Added missing early-out in AddPolyline() and AddConvexPolyFilled() when

imgui_widgets.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4317,7 +4317,16 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
43174317
else if (IsKeyPressed(ImGuiKey_PageDown) && is_multiline) { state->OnKeyPressed(STB_TEXTEDIT_K_PGDOWN | k_mask); scroll_y += row_count_per_page * g.FontSize; }
43184318
else if (IsKeyPressed(ImGuiKey_Home)) { state->OnKeyPressed(io.KeyCtrl ? STB_TEXTEDIT_K_TEXTSTART | k_mask : STB_TEXTEDIT_K_LINESTART | k_mask); }
43194319
else if (IsKeyPressed(ImGuiKey_End)) { state->OnKeyPressed(io.KeyCtrl ? STB_TEXTEDIT_K_TEXTEND | k_mask : STB_TEXTEDIT_K_LINEEND | k_mask); }
4320-
else if (IsKeyPressed(ImGuiKey_Delete) && !is_readonly && !is_cut) { state->OnKeyPressed(STB_TEXTEDIT_K_DELETE | k_mask); }
4320+
else if (IsKeyPressed(ImGuiKey_Delete) && !is_readonly && !is_cut)
4321+
{
4322+
if (!state->HasSelection())
4323+
{
4324+
// OSX doesn't seem to have Super+Delete to delete until end-of-line, so we don't emulate that (as opposed to Super+Backspace)
4325+
if (is_wordmove_key_down)
4326+
state->OnKeyPressed(STB_TEXTEDIT_K_WORDRIGHT | STB_TEXTEDIT_K_SHIFT);
4327+
}
4328+
state->OnKeyPressed(STB_TEXTEDIT_K_DELETE | k_mask);
4329+
}
43214330
else if (IsKeyPressed(ImGuiKey_Backspace) && !is_readonly)
43224331
{
43234332
if (!state->HasSelection())

0 commit comments

Comments
 (0)