fixed the on_pressed event on the bbox

This commit is contained in:
Faraphel 2023-02-14 13:43:22 +01:00
parent 4240ac71cc
commit 3db2ea3c9a
2 changed files with 9 additions and 6 deletions

View file

@ -44,7 +44,7 @@ class TestScene(Scene):
batch=self.background_batch,
)
label = self.add_widget(
button = self.add_widget(
Button,
x=0.5, y=0.5, width=0.5, height=0.5,
@ -59,8 +59,8 @@ class TestScene(Scene):
label_batch=self.label_batch,
)
label.on_pressed = lambda button, modifiers: window.set_scene(TestScene2)
label.on_release = lambda button, modifiers: print("release", label, button, modifiers)
button.on_pressed = lambda button, modifiers: "pass"
button.on_release = lambda button, modifiers: window.set_scene(TestScene2)
input_ = self.add_widget(
Input,
@ -71,7 +71,7 @@ class TestScene(Scene):
texture_active=region_input_active,
texture_error=region_input_error,
# 4 numéros de 1 à 3 chiffres aséparés par des points (IP), optionnellement suivi
# 4 numéros de 1 à 3 chiffres séparés par des points (IP), optionnellement suivi
# de deux points ainsi que de 1 à 5 chiffres (port)
regex=r"\d{1,3}(\.\d{1,3}){3}(:\d{1,5})?",
@ -89,6 +89,9 @@ class TestScene2(Scene):
def __init__(self, window: "Window"):
super().__init__(window)
def on_draw(self):
self.window.clear()
# Create a new window
window = Window(resizable=True, vsync=False)

View file

@ -142,7 +142,7 @@ class BoxWidget(Widget, ABC):
self.activated = True # if the click is inside the bbox, enable the activated state
self.clicking = True # the widget is now clicked
self.on_press(button, modifiers)
self.on_pressed(button, modifiers)
def on_mouse_release(self, x: int, y: int, button: int, modifiers: int):
old_click: bool = self._clicking
@ -153,7 +153,7 @@ class BoxWidget(Widget, ABC):
# if this button was the one hovered when the click was pressed
if old_click: self.on_release(button, modifiers)
def on_press(self, button: int, modifiers: int):
def on_pressed(self, button: int, modifiers: int):
"""
This event is called when the bbox is pressed
"""