@@ -103,9 +103,11 @@ def render(self, rect: rl.Rectangle = None) -> bool | int | None:
103103 ret = self ._render (self ._rect )
104104
105105 # Keep track of whether mouse down started within the widget's rectangle
106- if self .enabled :
106+ if self .enabled and self . __was_awake :
107107 self ._process_mouse_events ()
108108
109+ self .__was_awake = device .awake
110+
109111 return ret
110112
111113 def _process_mouse_events (self ) -> None :
@@ -117,21 +119,22 @@ def _process_mouse_events(self) -> None:
117119 continue
118120
119121 in_rect = rl .check_collision_point_rec (mouse_event .pos , hit_rect )
120-
121122 # Ignores touches/presses that start outside our rect
122123 # Allows touch to leave the rect and come back in focus if mouse did not release
123124 if mouse_event .left_pressed and touch_valid :
124125 if in_rect :
125126 self ._handle_mouse_press (mouse_event .pos )
126127 self .__is_pressed [mouse_event .slot ] = True
127128 self .__tracking_is_pressed [mouse_event .slot ] = True
129+ self ._handle_mouse_event (mouse_event )
128130
129131 # Callback such as scroll panel signifies user is scrolling
130132 elif not touch_valid :
131133 self .__is_pressed [mouse_event .slot ] = False
132134 self .__tracking_is_pressed [mouse_event .slot ] = False
133135
134136 elif mouse_event .left_released :
137+ self ._handle_mouse_event (mouse_event )
135138 if self .__is_pressed [mouse_event .slot ] and in_rect :
136139 self ._handle_mouse_release (mouse_event .pos )
137140 self .__is_pressed [mouse_event .slot ] = False
@@ -141,10 +144,12 @@ def _process_mouse_events(self) -> None:
141144 elif in_rect :
142145 if self .__tracking_is_pressed [mouse_event .slot ]:
143146 self .__is_pressed [mouse_event .slot ] = True
147+ self ._handle_mouse_event (mouse_event )
144148
145149 # Mouse/touch left our rect but may come back into focus later
146- else :
150+ elif not in_rect :
147151 self .__is_pressed [mouse_event .slot ] = False
152+ self ._handle_mouse_event (mouse_event )
148153
149154 @abc .abstractmethod
150155 def _render (self , rect : rl .Rectangle ) -> bool | int | None :
0 commit comments