mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-14 17:07:01 +00:00
Canceling text input with [esc] key uses stb_textedit facilities to restore original value. This makes restoration undoable using hotkeys.
Fixes #3008.
This commit is contained in:
parent
5a437f198c
commit
83efdcec8d
@ -76,6 +76,7 @@ Other Changes:
|
||||
those improvements in 1.73 makes them unnecessary. (#2722, #2770). [@rokups]
|
||||
- ColorEdit: "Copy As" context-menu tool shows hex values with a '#' prefix instead of '0x'.
|
||||
- ColorEdit: "Copy As" content-menu tool shows hex values both with/without alpha when available.
|
||||
- InputText: Fix crash when executing undo action after clearing input with ESC (#3008). [@rokups]
|
||||
- MenuBar: Fix minor clipping issue where occasionally a menu text can overlap the right-most border.
|
||||
- Window: Fix SetNextWindowBgAlpha(1.0f) failing to override alpha component. (#3007) [@Albog]
|
||||
- Window: When testing for the presence of the ImGuiWindowFlags_NoBringToFrontOnFocus flag we
|
||||
|
@ -3828,6 +3828,25 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
|
||||
{
|
||||
apply_new_text = state->InitialTextA.Data;
|
||||
apply_new_text_length = state->InitialTextA.Size - 1;
|
||||
|
||||
// Select all text
|
||||
state->OnKeyPressed(STB_TEXTEDIT_K_TEXTSTART);
|
||||
state->OnKeyPressed(STB_TEXTEDIT_K_TEXTEND | STB_TEXTEDIT_K_SHIFT);
|
||||
|
||||
// Paste converted text or empty buffer
|
||||
if (state->InitialTextA.size() > 1)
|
||||
{
|
||||
ImVector<ImWchar> w_text;
|
||||
const char* apply_new_text_end = apply_new_text + apply_new_text_length + 1;
|
||||
w_text.resize(ImTextCountCharsFromUtf8(apply_new_text, apply_new_text_end));
|
||||
ImTextStrFromUtf8(w_text.Data, w_text.Size, apply_new_text, apply_new_text_end);
|
||||
ImStb::stb_textedit_paste(state, &state->Stb, w_text.Data, w_text.Size);
|
||||
}
|
||||
else
|
||||
{
|
||||
ImWchar empty = 0;
|
||||
ImStb::stb_textedit_paste(state, &state->Stb, &empty, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user