Skip to content

Commit

Permalink
Fix error if button is initialized before app.
Browse files Browse the repository at this point in the history
  • Loading branch information
salt-die committed Mar 18, 2024
1 parent cf72f69 commit 8b84e3b
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/batgrl/gadgets/behaviors/button_behavior.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,13 @@ def button_state(self, button_state: ButtonState):
button_state = "normal"

self._button_state = button_state
dispatch[button_state]()
if self.root:
dispatch[button_state]()

def on_add(self):
"""Paint normal state on add."""
super().on_add()
self.update_normal()

def on_mouse(self, mouse_event) -> bool | None:
"""Determine button state from mouse event."""
Expand Down

0 comments on commit 8b84e3b

Please sign in to comment.