mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
Prevent the initial Changed event when initial value is True
This commit is contained in:
@@ -132,7 +132,14 @@ class ToggleButton(Static, can_focus=True):
|
||||
"""
|
||||
super().__init__(name=name, id=id, classes=classes, disabled=disabled)
|
||||
self._button_first = button_first
|
||||
self.value = value
|
||||
# WORKAROUND: I would `self.value = value` here but I don't want the
|
||||
# Changed event to fire off on the way in. I only want `Changed`
|
||||
# when it has *changed*, not when it's been set to the initial value
|
||||
# the user wants. This can be properly fixed if the `prevent`
|
||||
# context manager can be done.
|
||||
self._reactive_value = value
|
||||
# WORKAROUND: See above. This needs to be here for now too.
|
||||
self.set_class(self.value, "-on")
|
||||
self._label = Text.from_markup(label) if isinstance(label, str) else label
|
||||
try:
|
||||
# Only use the first line if it's a multi-line label.
|
||||
|
||||
Reference in New Issue
Block a user