@ -4185,14 +4185,16 @@ 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_reload_from_user_buf = ( state ! = NULL & & state - > ReloadUserBuf ) ;
const bool init_changed_specs = ( state ! = NULL & & state - > Stb . single_line ! = ! is_multiline ) ; // state != NULL means its our state.
const bool init_make_active = ( user_clicked | | user_scroll_finish | | input_requested_by_nav ) ;
const bool init_state = ( init_make_active | | user_scroll_active ) ;
if ( ( init_state & & g . ActiveId ! = id ) | | init_changed_specs )
if ( ( init_state & & g . ActiveId ! = id ) | | init_changed_specs | | init_reload_from_user_buf )
{
// Access state even if we don't own it yet.
state = & g . InputTextState ;
state - > CursorAnimReset ( ) ;
state - > ReloadUserBuf = false ;
// Backup state of deactivating item so they'll have a chance to do a write to output buffer on the same frame they report IsItemDeactivatedAfterEdit (#4714)
InputTextDeactivateHook ( state - > ID ) ;
@ -4204,8 +4206,8 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
memcpy ( state - > InitialTextA . Data , buf , buf_len + 1 ) ;
// Preserve cursor position and undo/redo stack if we come back to same widget
// FIXME: Since we reworked this on 2022/06, may want to differenc iate recycle_cursor vs recycle_undostate?
bool recycle_state = ( state - > ID = = id & & ! init_changed_specs ) ;
// FIXME: Since we reworked this on 2022/06, may want to different iate recycle_cursor vs recycle_undostate?
bool recycle_state = ( state - > ID = = id & & ! init_changed_specs & & ! init_reload_from_user_buf ) ;
if ( recycle_state & & ( state - > CurLenA ! = buf_len | | ( state - > TextAIsValid & & strncmp ( state - > TextA . Data , buf , buf_len ) ! = 0 ) ) )
recycle_state = false ;
@ -4230,7 +4232,13 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
stb_textedit_initialize_state ( & state - > Stb , ! is_multiline ) ;
}
if ( ! is_multiline )
if ( init_reload_from_user_buf )
{
state - > Stb . select_start = state - > ReloadSelectionStart ;
state - > Stb . cursor = state - > Stb . select_end = state - > ReloadSelectionEnd ;
state - > CursorClamp ( ) ;
}
else if ( ! is_multiline )
{
if ( flags & ImGuiInputTextFlags_AutoSelectAll )
select_all = true ;