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

GTK does not accept special keys in shortcuts #2414

Closed
RastislavKish opened this issue Feb 20, 2024 · 1 comment · Fixed by #2415
Closed

GTK does not accept special keys in shortcuts #2414

RastislavKish opened this issue Feb 20, 2024 · 1 comment · Fixed by #2415
Labels
bug A crash or error in behavior.

Comments

@RastislavKish
Copy link

RastislavKish commented Feb 20, 2024

Describe the bug

While the GTK backend can handle letter command shortcuts like Ctrl+L quite well, I'm unable to use Key.MOD_1+Key.SEMICOLON, Key.MOD_1+Key.PAGE_UP, Key.MOD_1+key.SPACE etc.

Steps to reproduce

  1. Run the Example Greeter app code below
  2. See the terminal output, Ctrl+; is also not visible in the Commands menu on the Greet command as a hint and can not be used to trigger the command.
(main.py:619420): Gtk-WARNING **: 20:31:22.372: Unable to parse accelerator '<Primary>;': ignored request to install 1 accelerators

(main.py:619420): Gtk-WARNING **: 20:31:22.408: Unable to parse accelerator '<Primary>;': ignored request to install 1 accelerators

Expected behavior

The shortcut should be registered properly and usable to activate its command, or, if this is not possible, the working / not working characters should be mentioned in the documentation.

Screenshots

No response

Environment

  • Operating System: Ubuntu Mate 22.04 64-bit
  • Python version: 3.10
  • Software versions:
    • Toga: 0.4.2

Logs


Additional context

The Greeter app code (a simple app that shows a greeting info_dialog upon activation of greet command:

import toga
from toga import Box, Command, Key

def greet(sender):
    app.main_window.info_dialog("Greeting", "Hello!",)

def build(app):
    app.commands.add(Command(greet,
        text="Greet",
        shortcut=Key.MOD_1+Key.SEMICOLON,
        ))

    return Box()

app=toga.App("Greeter", "com.example.greeter", startup=build)
app.main_loop()
@RastislavKish RastislavKish added the bug A crash or error in behavior. label Feb 20, 2024
@freakboy3742
Copy link
Member

Thanks for the report. Looking at the code, this all fell into a big "TODO" block of code. The fix for GTK was relatively straightforward, but Winforms had similar omissions, and Cocoa had a couple of errors.

I'll push a PR with a fix shortly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A crash or error in behavior.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants