-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Switch should stop the Click event from bubbling #2366
Copy link
Copy link
Closed
Labels
Description
At the moment Switch handles Click but then lets it bubble; there's no good reason to do that and it also stops the ability to write something like this:
from textual.app import App, ComposeResult
from textual.containers import Horizontal
from textual.widgets import Header, Footer, Label, Switch
class LabeledSwitch( Horizontal ):
def on_click( self ) -> None:
self.query_one(Switch).toggle()
class ClickableLabelApp( App[ None ] ):
def compose( self ) -> ComposeResult:
yield Header()
with LabeledSwitch():
yield Label( "Click me!" )
yield Switch()
yield Footer()
if __name__ == "__main__":
ClickableLabelApp().run()where the idea is to make a compound widget that lets you click on the Label or the Switch and the Switch will toggle -- only it doesn't work if you click on the Switch because it ends up double-toggling.
Reactions are currently unavailable