@@ -528,8 +528,8 @@ static int Widget_TriggerEventEx(LCUI_Widget widget, LCUI_WidgetEventPack pack)
528
528
break ;
529
529
}
530
530
default :
531
- if (widget -> trigger && 0 <
532
- EventTrigger_Trigger (widget -> trigger , e -> type , pack )) {
531
+ if (widget -> trigger &&
532
+ 0 < EventTrigger_Trigger (widget -> trigger , e -> type , pack )) {
533
533
return 0 ;
534
534
}
535
535
if (!widget -> parent || e -> cancel_bubble ) {
@@ -694,28 +694,37 @@ static LCUI_Widget GetSameParent(LCUI_Widget a, LCUI_Widget b)
694
694
return NULL;
695
695
}
696
696
697
- static LCUI_Widget Widget_GetActualEventTarget (LCUI_Widget widget )
697
+ static LCUI_Widget Widget_GetEventTarget (LCUI_Widget widget , float x , float y ,
698
+ int inherited_pointer_events )
698
699
{
699
- LCUI_BOOL found = FALSE;
700
- LCUI_Widget w = widget ;
700
+ int pointer_events ;
701
+
702
+ LCUI_Widget child ;
701
703
LCUI_Widget target = NULL ;
702
- LCUI_Widget root = LCUIWidget_GetRoot () ;
704
+ LinkedListNode * node ;
703
705
704
- while (w && w != root ) {
705
- if (w -> state == LCUI_WSTATE_DELETED ||
706
- w -> computed_style .pointer_events == SV_NONE ) {
707
- target = w -> parent ;
708
- found = TRUE;
709
- } else if (!found &&
710
- w -> computed_style .pointer_events == SV_AUTO ) {
711
- return widget ;
706
+ for (LinkedList_Each (node , & widget -> children_show )) {
707
+ child = node -> data ;
708
+ if (!child -> computed_style .visible ||
709
+ child -> state != LCUI_WSTATE_NORMAL ||
710
+ !LCUIRect_HasPoint (& child -> box .border , x , y )) {
711
+ continue ;
712
+ }
713
+ pointer_events = child -> computed_style .pointer_events ;
714
+ if (pointer_events == SV_INHERIT ) {
715
+ pointer_events = inherited_pointer_events ;
716
+ }
717
+ target = Widget_GetEventTarget (child , x - child -> box .padding .x ,
718
+ y - child -> box .padding .y ,
719
+ pointer_events );
720
+ if (target ) {
721
+ return target ;
722
+ }
723
+ if (pointer_events == SV_AUTO ) {
724
+ return child ;
712
725
}
713
- w = w -> parent ;
714
- }
715
- if (found ) {
716
- return target ;
717
726
}
718
- return widget ;
727
+ return target ;
719
728
}
720
729
721
730
static void Widget_TriggerMouseOverEvent (LCUI_Widget widget , LCUI_Widget parent )
@@ -913,15 +922,14 @@ static void OnMouseEvent(LCUI_SysEvent sys_ev, void *arg)
913
922
if (self .mouse_capturer ) {
914
923
target = self .mouse_capturer ;
915
924
} else {
916
- target = Widget_At (w , pos .x , pos .y );
917
- target = Widget_GetActualEventTarget (target );
925
+ target = Widget_GetEventTarget (w , pos .x , pos .y , SV_AUTO );
918
926
}
919
927
for (w = target ; w ; w = w -> parent ) {
920
928
if (w -> event_blocked ) {
921
929
return ;
922
930
}
923
931
}
924
- if (!target ) {
932
+ if (!target || target == LCUIWidget_GetRoot () ) {
925
933
Widget_OnMouseOverEvent (NULL );
926
934
switch (sys_ev -> type ) {
927
935
case LCUI_MOUSEDOWN :
0 commit comments