Open
Description
The code below fires a notification when you click the button.
from textual import on
from textual.app import App, ComposeResult
from textual.widgets import Button
class MyButton(Button):
pass
class MyApp(App[None]):
def compose(self) -> ComposeResult:
yield Button("Normal Button")
@on(MyButton.Pressed)
def notify_on_press_my_button(self) -> None:
self.notify("MyButton.Pressed matched!")
if __name__ == "__main__":
MyApp().run()
On clicking a Button
, I would not expect a handler decorated with @on(MyButton.Pressed)
to fire.
If I click a MyButton
, I'd expect a @on(Button.Pressed)
handler to fire, and I've confirmed this works as I expect.