Skip to content

Commit

Permalink
InputText: ImGuiInputTextCallbackData::InsertChars() accept (NULL,NUL…
Browse files Browse the repository at this point in the history
…L) range, in order to conform to common idioms. (#6565, #6566, #3615)
  • Loading branch information
ocornut committed Jul 3, 2023
1 parent 655aae5 commit 6417268
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions docs/CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ Other changes:
- CollapsingHeader/TreeNode: Fixed text padding when using _Framed+_Leaf flags. (#6549) [@BobbyAnguelov]
- InputText: Fixed not returning true when buffer is cleared while using the
ImGuiInputTextFlags_EscapeClearsAll flag. (#5688, #2620)
- InputText: ImGuiInputTextCallbackData::InsertChars() accept (NULL,NULL) range, in order to conform
to common idioms (e.g. passing .data(), .data() + .size() from a null string). (#6565, #6566, #3615)
- Combo: Made simple/legacy Combo() function not returns true when picking already selected item.
This is consistent with other widgets. If you need something else, you can use BeginCombo(). (#1182)
- Clipper: Rework inner logic to allow functioning with a zero-clear constructor.
Expand Down
4 changes: 4 additions & 0 deletions imgui_widgets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3873,6 +3873,10 @@ void ImGuiInputTextCallbackData::DeleteChars(int pos, int bytes_count)

void ImGuiInputTextCallbackData::InsertChars(int pos, const char* new_text, const char* new_text_end)
{
// Accept null ranges
if (new_text == new_text_end)
return;

const bool is_resizable = (Flags & ImGuiInputTextFlags_CallbackResize) != 0;
const int new_text_len = new_text_end ? (int)(new_text_end - new_text) : (int)strlen(new_text);
if (new_text_len + BufTextLen >= BufSize)
Expand Down

0 comments on commit 6417268

Please sign in to comment.