diff --git a/src/input.c b/src/input.c index 4a8fa2d..a5cdeb0 100644 --- a/src/input.c +++ b/src/input.c @@ -1296,6 +1296,10 @@ bool iui_switch(iui_context *ctx, /* Expand touch target for accessibility (48dp minimum per MD3) */ iui_rect_t touch_rect = track_rect; iui_expand_touch_target_h(&touch_rect, IUI_SWITCH_TOUCH_TARGET); + if (touch_rect.height > ctx->row_height) { + touch_rect.y = ctx->layout.y; + touch_rect.height = ctx->row_height; + } iui_state_t state = iui_get_component_state(ctx, touch_rect, false); diff --git a/src/internal.h b/src/internal.h index c7cd915..d26c056 100644 --- a/src/internal.h +++ b/src/internal.h @@ -507,8 +507,8 @@ static inline iui_vec2 iui_vec2_add(iui_vec2 a, iui_vec2 b) static inline bool in_rect(const iui_rect_t *rect, iui_vec2 pos) { - return ((pos.x >= rect->x) && (pos.x <= rect->x + rect->width) && - (pos.y >= rect->y) && (pos.y <= rect->y + rect->height)); + return ((pos.x >= rect->x) && (pos.x < rect->x + rect->width) && + (pos.y >= rect->y) && (pos.y < rect->y + rect->height)); } static inline void expand_rect(iui_rect_t *rect, float amount) diff --git a/tests/test-tracking.c b/tests/test-tracking.c index 24f3fe7..f108707 100644 --- a/tests/test-tracking.c +++ b/tests/test-tracking.c @@ -520,9 +520,9 @@ static void test_focus_switch_between_fields(void) ASSERT_TRUE(iui_textfield_is_registered(ctx, buf2)); /* Frame 2: Click on field 2 to transfer focus. - * Field 2 starts at ~96dp (after field 1), click at y=120. + * Field 2 is after field 1; click past ~96dp at y=119. */ - iui_update_mouse_pos(ctx, 150.0f, 120.0f); + iui_update_mouse_pos(ctx, 150.0f, 119.0f); iui_update_mouse_buttons(ctx, IUI_MOUSE_LEFT, 0); iui_begin_frame(ctx, 1.0f / 60.0f); iui_begin_window(ctx, "Test", 0, 0, 300, 300, 0);