Skip to content

Commit 3db4090

Browse files
committed
InputText() ImGuiInputTextFlags_CallbackAlways event set the EventFlag field of ImGuiTextEditCallbackData (#541)
1 parent 2065cbe commit 3db4090

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

imgui.cpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,7 @@
437437
- main: IsItemHovered() make it more consistent for various type of widgets, widgets with multiple components, etc. also effectively IsHovered() region sometimes differs from hot region, e.g tree nodes
438438
- main: IsItemHovered() info stored in a stack? so that 'if TreeNode() { Text; TreePop; } if IsHovered' return the hover state of the TreeNode?
439439
- input text: add ImGuiInputTextFlags_EnterToApply? (off #218)
440+
- input text: reorganise event handling, allow CharFilter to modify buffers, allow multiple events? (#541)
440441
- input text multi-line: don't directly call AddText() which does an unnecessary vertex reserve for character count prior to clipping. and/or more line-based clipping to AddText(). and/or reorganize TextUnformatted/RenderText for more efficiency for large text (e.g TextUnformatted could clip and log separately, etc).
441442
- input text multi-line: way to dynamically grow the buffer without forcing the user to initially allocate for worse case (follow up on #200)
442443
- input text multi-line: line numbers? status bar? (follow up on #200)
@@ -7547,8 +7548,10 @@ bool ImGui::InputTextEx(const char* label, char* buf, int buf_size, const ImVec2
75477548
event_flag = ImGuiInputTextFlags_CallbackHistory;
75487549
event_key = ImGuiKey_DownArrow;
75497550
}
7551+
else if (flags & ImGuiInputTextFlags_CallbackAlways)
7552+
event_flag = ImGuiInputTextFlags_CallbackAlways;
75507553

7551-
if (event_key != ImGuiKey_COUNT || (flags & ImGuiInputTextFlags_CallbackAlways) != 0)
7554+
if (event_flag)
75527555
{
75537556
ImGuiTextEditCallbackData callback_data;
75547557
memset(&callback_data, 0, sizeof(ImGuiTextEditCallbackData));

imgui.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,7 @@ enum ImGuiInputTextFlags_
488488
ImGuiInputTextFlags_EnterReturnsTrue = 1 << 5, // Return 'true' when Enter is pressed (as opposed to when the value was modified)
489489
ImGuiInputTextFlags_CallbackCompletion = 1 << 6, // Call user function on pressing TAB (for completion handling)
490490
ImGuiInputTextFlags_CallbackHistory = 1 << 7, // Call user function on pressing Up/Down arrows (for history handling)
491-
ImGuiInputTextFlags_CallbackAlways = 1 << 8, // Call user function every time
491+
ImGuiInputTextFlags_CallbackAlways = 1 << 8, // Call user function every time. User code may query cursor position, modify text buffer.
492492
ImGuiInputTextFlags_CallbackCharFilter = 1 << 9, // Call user function to filter character. Modify data->EventChar to replace/filter input, or return 1 to discard character.
493493
ImGuiInputTextFlags_AllowTabInput = 1 << 10, // Pressing TAB input a '\t' character into the text field
494494
ImGuiInputTextFlags_CtrlEnterForNewLine = 1 << 11, // In multi-line mode, allow exiting edition by pressing Enter. Ctrl+Enter to add new line (by default adds new lines with Enter).

0 commit comments

Comments
 (0)