@@ -612,6 +612,8 @@ def remove_section(self, section: Section) -> None:
612
612
section .on_hide_section ()
613
613
614
614
section ._view = None
615
+ if section in self .mouse_over_sections :
616
+ self .mouse_over_sections .remove (section )
615
617
self ._sections .remove (section )
616
618
617
619
# keep sections order updated in the lists of sections
@@ -940,7 +942,7 @@ def dispatch_mouse_enter_leave_events(
940
942
941
943
prevent_dispatch_el = EVENT_UNHANDLED # prevent dispatch for enter/leave events
942
944
for section in before_sections :
943
- if section not in current_sections :
945
+ if section . enabled and section not in current_sections :
944
946
if prevent_dispatch_el is EVENT_HANDLED :
945
947
break
946
948
# dispatch on_mouse_leave to before_section
@@ -1053,11 +1055,12 @@ def on_mouse_leave(self, x: int, y: int, *args, **kwargs) -> bool | None:
1053
1055
"""
1054
1056
prevent_dispatch = EVENT_UNHANDLED
1055
1057
for section in self .mouse_over_sections :
1056
- if prevent_dispatch is EVENT_HANDLED :
1057
- break
1058
- prevent_dispatch = self .dispatch_mouse_event (
1059
- "on_mouse_leave" , x , y , * args , ** kwargs , current_section = section
1060
- )
1058
+ if section .enabled :
1059
+ if prevent_dispatch is EVENT_HANDLED :
1060
+ break
1061
+ prevent_dispatch = self .dispatch_mouse_event (
1062
+ "on_mouse_leave" , x , y , * args , ** kwargs , current_section = section
1063
+ )
1061
1064
# clear the sections the mouse is over as it's out of the screen
1062
1065
self .mouse_over_sections = []
1063
1066
return prevent_dispatch
0 commit comments