@@ -20,8 +20,6 @@ class DialogResult(IntEnum):
2020
2121
2222class Widget (abc .ABC ):
23- LONG_PRESS_TIME = 0.5
24-
2523 def __init__ (self ):
2624 self ._rect : rl .Rectangle = rl .Rectangle (0 , 0 , 0 , 0 )
2725 self ._parent_rect : rl .Rectangle | None = None
@@ -35,10 +33,6 @@ def __init__(self):
3533 self ._multi_touch = False
3634 self .__was_awake = True
3735
38- # Long press state (single touch only, slot 0)
39- self ._long_press_start_t : float | None = None
40- self ._long_press_fired : bool = False
41-
4236 @property
4337 def rect (self ) -> rl .Rectangle :
4438 return self ._rect
@@ -133,28 +127,19 @@ def _process_mouse_events(self) -> None:
133127 self ._handle_mouse_press (mouse_event .pos )
134128 self .__is_pressed [mouse_event .slot ] = True
135129 self .__tracking_is_pressed [mouse_event .slot ] = True
136- if mouse_event .slot == 0 :
137- self ._long_press_start_t = rl .get_time ()
138- self ._long_press_fired = False
139130 self ._handle_mouse_event (mouse_event )
140131
141132 # Callback such as scroll panel signifies user is scrolling
142133 elif not touch_valid :
143134 self .__is_pressed [mouse_event .slot ] = False
144135 self .__tracking_is_pressed [mouse_event .slot ] = False
145- if mouse_event .slot == 0 :
146- self ._long_press_start_t = None
147- self ._long_press_fired = False
148136
149137 elif mouse_event .left_released :
150138 self ._handle_mouse_event (mouse_event )
151- if self .__is_pressed [mouse_event .slot ] and mouse_in_rect and not ( mouse_event . slot == 0 and self . _long_press_fired ) :
139+ if self .__is_pressed [mouse_event .slot ] and mouse_in_rect :
152140 self ._handle_mouse_release (mouse_event .pos )
153141 self .__is_pressed [mouse_event .slot ] = False
154142 self .__tracking_is_pressed [mouse_event .slot ] = False
155- if mouse_event .slot == 0 :
156- self ._long_press_start_t = None
157- self ._long_press_fired = False
158143
159144 # Mouse/touch is still within our rect
160145 elif mouse_in_rect :
@@ -165,17 +150,8 @@ def _process_mouse_events(self) -> None:
165150 # Mouse/touch left our rect but may come back into focus later
166151 elif not mouse_in_rect :
167152 self .__is_pressed [mouse_event .slot ] = False
168- if mouse_event .slot == 0 :
169- self ._long_press_start_t = None
170- self ._long_press_fired = False
171153 self ._handle_mouse_event (mouse_event )
172154
173- # Long press detection
174- if self ._long_press_start_t is not None and not self ._long_press_fired :
175- if (rl .get_time () - self ._long_press_start_t ) >= self .LONG_PRESS_TIME :
176- self ._long_press_fired = True
177- self ._handle_long_press (gui_app .last_mouse_event .pos )
178-
179155 def _layout (self ) -> None :
180156 """Optionally lay out child widgets separately. This is called before rendering."""
181157
@@ -199,11 +175,9 @@ def _handle_mouse_release(self, mouse_pos: MousePos) -> bool:
199175 self ._click_callback ()
200176 return False
201177
202- def _handle_long_press (self , mouse_pos : MousePos ) -> None :
203- """Optionally handle a long-press gesture."""
204-
205178 def _handle_mouse_event (self , mouse_event : MouseEvent ) -> None :
206179 """Optionally handle mouse events. This is called before rendering."""
180+ # Default implementation does nothing, can be overridden by subclasses
207181
208182 def show_event (self ):
209183 """Optionally handle show event. Parent must manually call this"""
0 commit comments