@@ -52,6 +52,10 @@ def __init__(self, initial_state: bool = False, width: int = TOGGLE_WIDTH, enabl
5252 self .toggle = Toggle (initial_state = initial_state )
5353 self .state = initial_state
5454
55+ def set_touch_valid_callback (self , touch_callback : Callable [[], bool ]) -> None :
56+ super ().set_touch_valid_callback (touch_callback )
57+ self .toggle .set_touch_valid_callback (touch_callback )
58+
5559 def _render (self , rect : rl .Rectangle ) -> bool :
5660 self .toggle .set_enabled (self .enabled )
5761 self .toggle .render (rl .Rectangle (rect .x , rect .y + (rect .height - TOGGLE_HEIGHT ) / 2 , self ._rect .width , TOGGLE_HEIGHT ))
@@ -163,7 +167,7 @@ def _render(self, rect: rl.Rectangle) -> bool:
163167 # Check button state
164168 mouse_pos = rl .get_mouse_position ()
165169 is_hovered = rl .check_collision_point_rec (mouse_pos , button_rect )
166- is_pressed = is_hovered and rl .is_mouse_button_down (rl .MouseButton .MOUSE_BUTTON_LEFT )
170+ is_pressed = is_hovered and rl .is_mouse_button_down (rl .MouseButton .MOUSE_BUTTON_LEFT ) and self . _is_pressed
167171 is_selected = i == self .selected_button
168172
169173 # Button colors
@@ -184,7 +188,7 @@ def _render(self, rect: rl.Rectangle) -> bool:
184188 rl .draw_text_ex (self ._font , text , rl .Vector2 (text_x , text_y ), 40 , 0 , rl .Color (228 , 228 , 228 , 255 ))
185189
186190 # Handle click
187- if is_hovered and rl .is_mouse_button_released (rl .MouseButton .MOUSE_BUTTON_LEFT ):
191+ if is_hovered and rl .is_mouse_button_released (rl .MouseButton .MOUSE_BUTTON_LEFT ) and self . _is_pressed :
188192 clicked = i
189193
190194 if clicked >= 0 :
@@ -216,6 +220,11 @@ def __init__(self, title: str = "", icon: str | None = None, description: str |
216220 self ._prev_description : str | None = None
217221 self ._description_height : float = 0
218222
223+ def set_touch_valid_callback (self , touch_callback : Callable [[], bool ]) -> None :
224+ super ().set_touch_valid_callback (touch_callback )
225+ if self .action_item :
226+ self .action_item .set_touch_valid_callback (touch_callback )
227+
219228 def set_parent_rect (self , parent_rect : rl .Rectangle ):
220229 super ().set_parent_rect (parent_rect )
221230 self ._rect .width = parent_rect .width
0 commit comments