Open kenodegard opened 4 years ago
Hi @njalerikson,
It should be possible to override this by using the eager=True
parameter: https://python-prompt-toolkit.readthedocs.io/en/master/pages/advanced_topics/key_bindings.html#eager
Because otherwise indeed, control specific key binding have priority over the global key bindings.
In this particular case, I'm not against making these key bindings global, passing them to the Application
and merging in extra key bindings. ProgressBar
could accept an extra_key_bindings
argument, and then we use merge_key_bindings()
, to merge them together. Feel free to create a PR for that.
So a progress bar has two sets of keybindings in use. The standard keybindings for "c-l" and "c-c" assigned to
_ProgressControl
(created bycreate_key_bindings
):https://github.com/prompt-toolkit/python-prompt-toolkit/blob/5ee9df2417f41d6d374b0a716156141061a8ac8f/prompt_toolkit/shortcuts/progress_bar/base.py#L275-L283
https://github.com/prompt-toolkit/python-prompt-toolkit/blob/5ee9df2417f41d6d374b0a716156141061a8ac8f/prompt_toolkit/shortcuts/progress_bar/base.py#L69-L85
and whatever keybindings the user provides which are passed to the
Application
. https://github.com/prompt-toolkit/python-prompt-toolkit/blob/5ee9df2417f41d6d374b0a716156141061a8ac8f/prompt_toolkit/shortcuts/progress_bar/base.py#L187-L205This means, for example, that I cannot overwrite the "c-c" keybinding. Why are there two 2 sets of key bindings and what would be the correct way to overwrite the bindings?