@@ -612,6 +612,8 @@ def remove_section(self, section: Section) -> None:
612612 section .on_hide_section ()
613613
614614 section ._view = None
615+ if section in self .mouse_over_sections :
616+ self .mouse_over_sections .remove (section )
615617 self ._sections .remove (section )
616618
617619 # keep sections order updated in the lists of sections
@@ -940,7 +942,7 @@ def dispatch_mouse_enter_leave_events(
940942
941943 prevent_dispatch_el = EVENT_UNHANDLED # prevent dispatch for enter/leave events
942944 for section in before_sections :
943- if section not in current_sections :
945+ if section . enabled and section not in current_sections :
944946 if prevent_dispatch_el is EVENT_HANDLED :
945947 break
946948 # dispatch on_mouse_leave to before_section
@@ -1053,11 +1055,12 @@ def on_mouse_leave(self, x: int, y: int, *args, **kwargs) -> bool | None:
10531055 """
10541056 prevent_dispatch = EVENT_UNHANDLED
10551057 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+ )
10611064 # clear the sections the mouse is over as it's out of the screen
10621065 self .mouse_over_sections = []
10631066 return prevent_dispatch
0 commit comments