textual: As of 0.6.0, bindings on (at least) `left`, `right`, `up` and `down` no longer appear to work
With Textual 0.5.0 I had bindings on the arrow keys that worked fine. Having upgraded to 0.6.0 those bindings no longer seem to work. Isolating the issue I can recreate with this code (some other keys thrown in as control tests)
from textual.app import App, ComposeResult
from textual.widgets import TextLog, Header, Footer
from textual.binding import Binding
from textual.events import Key
class Binder( App[ None ] ):
CSS = """
TextLog {
background: #222200;
color: #BBBB00;
text-style: bold;
}
"""
BINDINGS = [
Binding( "up", "log( 'up' )", "Up" ),
Binding( "down", "log( 'down' )", "Down" ),
Binding( "left", "log( 'left' )", "Left" ),
Binding( "right", "log( 'right' )", "Right" ),
Binding( "a", "log( 'a' )", "a" ),
Binding( "s", "log( 's' )", "s" ),
Binding( "d", "log( 'd' )", "d" ),
Binding( "f", "log( 'f' )", "f" ),
Binding( "left_square_bracket", "log( '[' )", "[" ),
Binding( "right_square_bracket", "log( ']' )", "]" ),
]
def compose( self ) -> ComposeResult:
yield Header()
yield TextLog()
yield Footer()
def on_mount( self ) -> None:
self.query_one( TextLog ).write( "Ready..." )
self.query_one( TextLog ).write( "Key bindings being looked for:" )
self.query_one( TextLog ).write( ", ".join(
[ binding.key for binding in self.BINDINGS ]
) )
def action_log( self, name: str ) -> None:
self.query_one( TextLog ).write( f"Via binding: {name}" )
def on_key( self, event: Key ) -> None:
self.query_one( TextLog ).write( f"Via event: {event!r}" )
if __name__ == "__main__":
Binder().run()
Running the above, pressing the arrow keys vs some of the other keys…

About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 21 (19 by maintainers)
Commits related to this issue
- Start unit tests for live key bindings plus inheriting Up until now there doesn't seem to have been any unit tests aimed squarely at setting up bindings, as part of a running application, which are o... — committed to davep/textual by davep 2 years ago
- Make it clear, in the code, that all containers are considered scrollable The code is exactly the same between is_container and is_scrollable, and the intent (confirmed in https://github.com/Textuali... — committed to davep/textual by davep 2 years ago
- Add a test for a screen binding movement, wrapping a focusable widget This is the heart of the issue introduced by https://github.com/Textualize/textual/pull/1170/commits/b48a1402b8103ca16d5e33853862... — committed to davep/textual by davep 2 years ago
- Add test for focused widget, no inherit, empty BINDINGS Testing the overlap between #1343 and #1351. — committed to davep/textual by davep 2 years ago
- :zap: Make the cursor keys work again Due to binding inheritance being introduced in 0.6.0, the cursor keys stopped working in the app. The issue is that they're getting consumed by widgets *below* t... — committed to davep/oidia by davep 2 years ago
- Make the cursor keys work in 5x5 again The cursor keys stopped working in 5x5 once binding inheritance was introduced in 0.6.0 (see #1343). Making them `universal` keys here fixes the issue. This won... — committed to davep/textual by davep 2 years ago
- Rename the binding `universal` argument to `priority` As per https://github.com/Textualize/textual/issues/1343#issuecomment-1351087237 — committed to davep/textual by davep 2 years ago
- Add support for a default priority for Bindings This commit changes things slightly so that the priority of a binding is an three-state: True, False or None. True and False are firm choices that noth... — committed to davep/textual by davep 2 years ago
- Add support for a PRIORITY_BINDINGS classvar This works in conjunction with BINDINGS. If a widget has BINDINGS, and if any of those bindings have a priority that isn't True or False, the value of PRI... — committed to davep/textual by davep 2 years ago
- Make bindings on Screen and child classes priority by default As requested by @willmcgugan while discussing #1343. — committed to davep/textual by davep 2 years ago
- Make bindings on App and child classes priority by default As requested by @willmcgugan while discussing #1343. — committed to davep/textual by davep 2 years ago
- Update the binding inheritance tests to reflect the emerging changes I feel some more will be needed, but this is all of the basics, hitting all of the important points that relate to #1343. More imp... — committed to davep/textual by davep 2 years ago
They are the same thing for the base class, and most widgets. But it is possible for something to be scrollable that is not a container. I think the only one we have is
ScrollView.