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.
At the moment
SwitchhandlesClickbut then lets it bubble; there's no good reason to do that and it also stops the ability to write something like this:where the idea is to make a compound widget that lets you click on the
Labelor theSwitchand theSwitchwill toggle -- only it doesn't work if you click on theSwitchbecause it ends up double-toggling.