From 3db2ea3c9aea9fbf359aad3a6b5ead560f12ee5c Mon Sep 17 00:00:00 2001 From: Faraphel Date: Tue, 14 Feb 2023 13:43:22 +0100 Subject: [PATCH] fixed the on_pressed event on the bbox --- main.pyw | 11 +++++++---- source/gui/widget/abc/BoxWidget.py | 4 ++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/main.pyw b/main.pyw index 020482f..7c948fb 100644 --- a/main.pyw +++ b/main.pyw @@ -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) diff --git a/source/gui/widget/abc/BoxWidget.py b/source/gui/widget/abc/BoxWidget.py index 94a0af5..7ea4503 100644 --- a/source/gui/widget/abc/BoxWidget.py +++ b/source/gui/widget/abc/BoxWidget.py @@ -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 """