8000 Merge pull request #2702 from alejcas/fix-sections · pythonarcade/arcade@fbafcb5 · GitHub
[go: up one dir, main page]

Skip to content

Commit fbafcb5

Browse files
authored
Merge pull request #2702 from alejcas/fix-sections
Fix for mouse enter/leave events when a section is disabled or removed
2 parents 3b2acb1 + cd5357e commit fbafcb5

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

arcade/sections.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)
0