mirror of
https://github.com/Drezil/imgui.git
synced 2024-12-22 15:46:35 +00:00
InputText: Fixed swiching from single to multi-line while preserving same ID.
This commit is contained in:
parent
97265602c4
commit
d4f08d893e
@ -69,6 +69,7 @@ Other Changes:
|
||||
- Checkbox: Added CheckboxFlags() helper with int* type.
|
||||
- InputText: Fixed updating cursor/selection position when a callback altered the buffer in a way
|
||||
where the byte count is unchanged but the decoded character count changes. (#3587) [@gqw]
|
||||
- InputText: Fixed swiching from single to multi-line while preserving same ID.
|
||||
- Nav: Fixed IsItemFocused() from returning false when Nav highlight is hidden because mouse has moved.
|
||||
It's essentially been always the case but it doesn't make much sense. Instead we will aim at exposing
|
||||
feedback and control of keyboard/gamepad navigation highlight and mouse hover disable flag. (#787, #2048)
|
||||
|
@ -3857,9 +3857,10 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
|
||||
|
||||
float scroll_y = is_multiline ? draw_window->Scroll.y : FLT_MAX;
|
||||
|
||||
const bool init_changed_specs = (state != NULL && state->Stb.single_line != !is_multiline);
|
||||
const bool init_make_active = (focus_requested || user_clicked || user_scroll_finish || user_nav_input_start);
|
||||
const bool init_state = (init_make_active || user_scroll_active);
|
||||
if (init_state && g.ActiveId != id)
|
||||
if ((init_state && g.ActiveId != id) || init_changed_specs)
|
||||
{
|
||||
// Access state even if we don't own it yet.
|
||||
state = &g.InputTextState;
|
||||
@ -3881,7 +3882,7 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
|
||||
|
||||
// Preserve cursor position and undo/redo stack if we come back to same widget
|
||||
// FIXME: For non-readonly widgets we might be able to require that TextAIsValid && TextA == buf ? (untested) and discard undo stack if user buffer has changed.
|
||||
const bool recycle_state = (state->ID == id);
|
||||
const bool recycle_state = (state->ID == id && !init_changed_specs);
|
||||
if (recycle_state)
|
||||
{
|
||||
// Recycle existing cursor/selection/undo stack but clamp position
|
||||
|
Loading…
Reference in New Issue
Block a user