@@ -751,17 +751,16 @@ bool iui_edit_with_selection(iui_context *ctx,
751751 state -> is_dragging = false;
752752 }
753753
754- /* Handle keyboard input when focused */
754+ /* Handle keyboard input when focused and auto-scroll to keep cursor visible
755+ */
755756 if (has_focus ) {
756757 modified =
757758 iui_process_text_input_selection (ctx , buffer , buffer_size , state );
758759 /* Reset cursor blink on any key activity */
759760 if (ctx -> key_pressed != IUI_KEY_NONE || ctx -> char_input != 0 )
760761 ctx -> cursor_blink = 0.f ;
761- }
762762
763- /* Auto-scroll to keep cursor visible */
764- if (has_focus ) {
763+ /* Auto-scroll to keep cursor visible */
765764 float cursor_x_in_text =
766765 textfield_get_width_to_pos (ctx , buffer , state -> cursor , false);
767766 if (cursor_x_in_text < state -> scroll_offset )
@@ -990,7 +989,8 @@ iui_textfield_result iui_textfield_with_selection(
990989 has_focus = false;
991990 state -> is_dragging = false;
992991 }
993- } else if (opts .disabled && has_focus ) {
992+ } else if (has_focus ) {
993+ /* Widget is disabled but still has focus - clear it */
994994 ctx -> focused_edit = NULL ;
995995 has_focus = false;
996996 }
@@ -1217,15 +1217,11 @@ bool iui_switch(iui_context *ctx,
12171217 }
12181218 }
12191219
1220- /* Apply focus state layer */
1220+ /* Apply focus state layer and draw focus ring when focused */
12211221 if (is_focused ) {
12221222 uint32_t focus_layer =
12231223 iui_state_layer (ctx -> colors .primary , IUI_STATE_FOCUS_ALPHA );
12241224 track_color = iui_blend_color (track_color , focus_layer );
1225- }
1226-
1227- /* Draw focus ring when focused */
1228- if (is_focused ) {
12291225 iui_draw_focus_ring (ctx , track_rect , corner );
12301226 }
12311227
@@ -1525,16 +1521,14 @@ bool iui_dropdown(iui_context *ctx, const iui_dropdown_options *options)
15251521 }
15261522
15271523 /* Draw floating label */
1528- float label_y ;
1529- uint32_t label_color =
1530- options -> disabled
1531- ? iui_state_layer (ctx -> colors .on_surface_variant ,
1532- IUI_STATE_DISABLE_ALPHA )
1533- : (is_open ? ctx -> colors .primary : ctx -> colors .on_surface_variant );
1534-
15351524 if (options -> label ) {
1525+ uint32_t label_color =
1526+ options -> disabled ? iui_state_layer (ctx -> colors .on_surface_variant ,
1527+ IUI_STATE_DISABLE_ALPHA )
1528+ : (is_open ? ctx -> colors .primary
1529+ : ctx -> colors .on_surface_variant );
15361530 /* Label floats above when there's a selection */
1537- label_y = field_rect .y + 8.f ;
1531+ float label_y = field_rect .y + 8.f ;
15381532 iui_internal_draw_text (ctx , field_rect .x + padding , label_y ,
15391533 options -> label , label_color );
15401534 }
0 commit comments