From: Skullheadx <94652084+Skullheadx@users.noreply.github.com> Date: Fri, 14 Apr 2023 12:49:30 +0000 (-0400) Subject: reset cooldown + add color change for mouse over X-Git-Url: http://git.skullheadx.com/projects/tech/index.html?a=commitdiff_plain;h=342e1ff557f252e3bc099467f108f1fb467f043d;p=PygameGUIEngine.git reset cooldown + add color change for mouse over --- diff --git a/button.py b/button.py index ce88a25..d774d0c 100644 --- a/button.py +++ b/button.py @@ -4,7 +4,7 @@ from text import Label class Button(Label): - cooldown = 1 # seconds + cooldown = 0.25 # seconds def __init__(self, x, y, text, font, size, text_color=Color.BLACK, background=Color.WHITE, border_color=Color.BLACK, border_width=1, border_radius=0, padding=10, func=None): @@ -34,6 +34,10 @@ class Button(Label): if not mouse_pressed: self.click_disabled = False else: + if self.is_hover: + self.rect.set_background_color(self.hover_color) + else: + self.rect.set_background_color(self.background_color) return self.is_clicked = self.is_hover and not mouse_pressed and self.is_pressed self.is_pressed = self.is_hover and mouse_pressed