Skip to content

Commit

Permalink
Simplify button event handling.
Browse files Browse the repository at this point in the history
  • Loading branch information
freakboy3742 committed Aug 7, 2023
1 parent 93388b6 commit 2ccd4f5
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 7 deletions.
2 changes: 1 addition & 1 deletion textual/src/toga_textual/widgets/button.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def __init__(self, impl):
self.interface = impl.interface
self.impl = impl

def on_press(self, event: TextualButton.Pressed) -> None:
def on_button_pressed(self, event: TextualButton.Pressed) -> None:
self.interface.on_press(None)


Expand Down
7 changes: 1 addition & 6 deletions textual/src/toga_textual/window.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from textual.screen import Screen as TextualScreen
from textual.widgets import Button as TextualButton, Header as TextualHeader
from textual.widgets import Header as TextualHeader

from .container import Container

Expand All @@ -13,11 +13,6 @@ def __init__(self, impl):
def on_mount(self) -> None:
self.mount(TextualHeader())

# Textual catches events at the level of the Screen/Window;
# redirect to the widget instance.
def on_button_pressed(self, event: TextualButton.Pressed) -> None:
event.button.on_press(event)


class Window:
def __init__(self, interface, title, position, size):
Expand Down

0 comments on commit 2ccd4f5

Please sign in to comment.