File tree Expand file tree Collapse file tree 2 files changed +7
-5
lines changed Expand file tree Collapse file tree 2 files changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1212- Fixed bindings persistance https://github.com/Textualize/textual/issues/1613
1313- The ` Markdown ` widget now auto-increments ordered lists https://github.com/Textualize/textual/issues/2002
1414- Fixed modal bindings https://github.com/Textualize/textual/issues/2194
15-
15+ - Fix binding enter to active button https://github.com/Textualize/textual/issues/2194
1616
1717## [ 0.17.1] - 2023-03-30
1818
Original file line number Diff line number Diff line change 77from typing_extensions import Literal , Self
88
99from .. import events
10+ from ..binding import Binding
1011from ..css ._error_tools import friendly_list
1112from ..message import Message
1213from ..reactive import reactive
@@ -145,6 +146,8 @@ class Button(Static, can_focus=True):
145146
146147 """
147148
149+ BINDINGS = [Binding ("enter" , "press" , "Press Button" , show = False )]
150+
148151 ACTIVE_EFFECT_DURATION = 0.3
149152 """When buttons are clicked they get the `-active` class for this duration (in seconds)"""
150153
@@ -252,10 +255,9 @@ def _start_active_affect(self) -> None:
252255 self .ACTIVE_EFFECT_DURATION , partial (self .remove_class , "-active" )
253256 )
254257
255- async def _on_key (self , event : events .Key ) -> None :
256- if event .key == "enter" and not self .disabled :
257- self ._start_active_affect ()
258- self .post_message (Button .Pressed (self ))
258+ def action_press (self ) -> None :
259+ """Activate a press if"""
260+ self .press ()
259261
260262 @classmethod
261263 def success (
You can’t perform that action at this time.
0 commit comments