mirror of
https://github.com/ocornut/imgui.git
synced 2026-01-25 02:24:24 +00:00
InputText: added mGuiInputTextCallbackData::EventActive helpers. (#9174)
This commit is contained in:
parent
d448045669
commit
cb3b7ff4fb
3 changed files with 7 additions and 3 deletions
|
|
@ -155,9 +155,9 @@ Other Changes:
|
|||
next to each components, in multi-components functions.
|
||||
- Added a way to select a specific marker color.
|
||||
- InputText:
|
||||
- Made ImGuiInputTextCallbackData::SelectAll() also sets CursorPos to SelectionEnd.
|
||||
- Added ImGuiInputTextCallbackData::SetSelection() helper.
|
||||
- Added ImGuiInputTextCallbackData::ID field.
|
||||
- ImGuiInputTextCallbackData: SelectAll() also sets CursorPos to SelectionEnd.
|
||||
- ImGuiInputTextCallbackData: Added SetSelection() helper.
|
||||
- ImGuiInputTextCallbackData: Added ID and EventActive helpers. (#9174)
|
||||
- Text, InputText:
|
||||
- Reworked word-wrapping logic:
|
||||
- Try to not wrap in the middle of contiguous punctuations. (#8139, #8439, #9094)
|
||||
|
|
|
|||
1
imgui.h
1
imgui.h
|
|
@ -2638,6 +2638,7 @@ struct ImGuiInputTextCallbackData
|
|||
// - If you know your edits are not going to resize the underlying buffer allocation, you may modify the contents of 'Buf[]' directly. You need to update 'BufTextLen' accordingly (0 <= BufTextLen < BufSize) and set 'BufDirty'' to true so InputText can update its internal state.
|
||||
ImGuiKey EventKey; // Key pressed (Up/Down/TAB) // Read-only // [Completion,History]
|
||||
ImWchar EventChar; // Character input // Read-write // [CharFilter] Replace character with another one, or set to zero to drop. return 1 is equivalent to setting EventChar=0;
|
||||
bool EventActivated; // Input field just got activated // Read-only // [Always]
|
||||
bool BufDirty; // Set if you modify Buf/BufTextLen! // Write // [Completion,History,Always]
|
||||
char* Buf; // Text buffer // Read-write // [Resize] Can replace pointer / [Completion,History,Always] Only write to pointed data, don't replace the actual pointer!
|
||||
int BufTextLen; // Text length (in bytes) // Read-write // [Resize,Completion,History,Always] Exclude zero-terminator storage. In C land: == strlen(some_text), in C++ land: string.length()
|
||||
|
|
|
|||
|
|
@ -4506,6 +4506,7 @@ static bool InputTextFilterCharacter(ImGuiContext* ctx, ImGuiInputTextState* sta
|
|||
callback_data.Flags = flags;
|
||||
callback_data.EventFlag = ImGuiInputTextFlags_CallbackCharFilter;
|
||||
callback_data.EventChar = (ImWchar)c;
|
||||
callback_data.EventActivated = (g.ActiveId == state->ID && g.ActiveIdIsJustActivated);
|
||||
callback_data.UserData = user_data;
|
||||
if (callback(&callback_data) != 0)
|
||||
return false;
|
||||
|
|
@ -5302,6 +5303,7 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
|
|||
callback_data.ID = id;
|
||||
callback_data.Flags = flags;
|
||||
callback_data.EventFlag = event_flag;
|
||||
callback_data.EventActivated = (g.ActiveId == state->ID && g.ActiveIdIsJustActivated);
|
||||
callback_data.UserData = callback_user_data;
|
||||
|
||||
// FIXME-OPT: Undo stack reconcile needs a backup of the data until we rework API, see #7925
|
||||
|
|
@ -5380,6 +5382,7 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
|
|||
callback_data.ID = id;
|
||||
callback_data.Flags = flags;
|
||||
callback_data.EventFlag = ImGuiInputTextFlags_CallbackResize;
|
||||
callback_data.EventActivated = (g.ActiveId == state->ID && g.ActiveIdIsJustActivated);
|
||||
callback_data.Buf = buf;
|
||||
callback_data.BufTextLen = apply_new_text_length;
|
||||
callback_data.BufSize = ImMax(buf_size, apply_new_text_length + 1);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue