Skip to content
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

Bindings inside apps are not combinied #3693

Closed
mohammad-sayed-ahmad opened this issue Nov 16, 2023 · 3 comments
Closed

Bindings inside apps are not combinied #3693

mohammad-sayed-ahmad opened this issue Nov 16, 2023 · 3 comments
Assignees
Labels
wontfix This will not be worked on

Comments

@mohammad-sayed-ahmad
Copy link

mohammad-sayed-ahmad commented Nov 16, 2023

Hello,
I have a dual language keyboard(Arabic/English) and I have noticed that when using 'BINDINGS' inside apps, bindings work only using the English keyboard mode when capslock is off. I am still new to textual but it seems mostly unhelpful to seperate each key from characters. Maybe you could add an extra option allowing you to toggle between character as typed and character as pressed.

class TestApp(App):
    BINDINGS = [
        Binding(key='d', action="toggle_dark_mode", description="Toggle Dark Mode")
    ]
    def compose(self):
        yield Header(show_clock=True)
        yield Footer()

    def action_toggle_dark_mode(self):
        self.dark = not self.dark
@TomJGooding
Copy link
Contributor

Could you try running textual keys (available from the Textual devtools) and see what keys turn up from your terminal?

It might also be helpful if you run textual diagnose and paste the results.

@Textualize Textualize deleted a comment from github-actions bot Nov 16, 2023
@rodrigogiraoserrao
Copy link
Contributor

Hey Mohammad, thanks for opening this issue!

d and Shift+d are effectively different key combinations and that's why pressing d while CapsLock is on won't trigger the binding for d.

I understand this might not have been what you expected.
If you wish, you can easily extend your BINDINGS to duplicate all letter bindings so that they work like you expected.
Feel free to head on to the Discord server if you need help implementing the change I suggested above.

I'm closing this issue as this is not a bug, it is expected behaviour, and we wish to keep distinguishing between d and Shift+d.

@rodrigogiraoserrao rodrigogiraoserrao closed this as not planned Won't fix, can't repro, duplicate, stale Nov 16, 2023
@rodrigogiraoserrao rodrigogiraoserrao self-assigned this Nov 16, 2023
@rodrigogiraoserrao rodrigogiraoserrao added the wontfix This will not be worked on label Nov 16, 2023
@Textualize Textualize deleted a comment from github-actions bot Nov 16, 2023
@rodrigogiraoserrao
Copy link
Contributor

rodrigogiraoserrao commented Nov 16, 2023

As far as the Arabic keyboard is concerned, the experiment of running textual keys like Tom suggests above will show you that we (read, Textual) can't really tell what key is being pressed, we can only try to guess based on what input the terminal gets when you press a key.

Thus, if you have your keyboard in Arabic, it is likely that pressing the key that would produce a d in English will be producing something quite different from a d, meaning we won't be able to trigger the keybinding that you expected to be triggered.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

3 participants