-
Notifications
You must be signed in to change notification settings - Fork 813
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dynamic actions sharing the same keybinding #4755
Comments
I think this the description of your bug, but let me know if I missed it.
So, the issue is that request to update the footer somehow gets stuck in a queue waiting for any other event to pop it out? |
@merriam Not quite, though if the footer isn't updating for you in the first example, you might try updating your version of Textual. This boils down to a fairly common question about how to change the description of a binding. For example, where the d key toggles dark mode, update the description to display 'Light Mode' when in dark mode and 'Dark' when in light mode. There's not currently a way of updating the binding description AFAIK. You can't bind a key to multiple actions so trying to use |
The issue is that you cannot change an action's description depending on the current state. For instance you can have "toggle dark mode" but not "enable dark mode" and "disable dark mode" on the same key, switching between the two depending on whether dark mode is currently active. |
I can see why this happens. The code makes the erroneous assumption that there is one binding per key. The fix is non-trivial, but required for such dynamic bindings! |
Don't forget to star the repository! Follow @textualizeio for Textual updates. |
Dynamic bindings/actions do not allow changing the description of a "toggle" action (e.g. dark mode / light mode, expand / collapse, lock / unlock) without also changing its key.
MRE
./DarkLight.py
successfully implements a toggle action using two actual actions with different keys (d: Light mode, e: Dark mode)SAME_BINDINGS= ./DarkLight.py
does the same but declares the two actual actions with the same key (d). Result: only the "quit" action is retained.Code
Textual Diagnostics
Versions
Python
Operating System
Terminal
Rich Console options
The text was updated successfully, but these errors were encountered: