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

Readonly Textinput beeps on focus loss with keyboard on GTK #2554

Open
freakboy3742 opened this issue May 6, 2024 · 3 comments
Open

Readonly Textinput beeps on focus loss with keyboard on GTK #2554

freakboy3742 opened this issue May 6, 2024 · 3 comments
Labels
bug A crash or error in behavior. good first issue Is this your first time contributing? This could be a good place to start! linux The issue relates Linux support.

Comments

@freakboy3742
Copy link
Member

Describe the bug

Under GTK, If a readonly text input loses focus as a result of keyboard input (i.e., pressing tab), a beep is emitted.

Steps to reproduce

  1. Run Tutorial 1
  2. Type Tab twice

A beep will be emitted when the Celsius field loses focus.

Expected behavior

No beep should be emitted.

Screenshots

No response

Environment

  • Operating System: Ubuntu 22.04
  • Python version: All
  • Software versions:
    • Toga: 0.4.2+

Logs


Additional context

No beep is emitted on loss of focus.

It's arguable whether the readonly widget should be able to accept focus at all - that's the behavior on macOS. If this is acceptable, calling native.set_can_focus() as part of set_readonly() might be a fix for this.

There is likely similar issues on any other widget with a clear input focus and a readonly option.

@freakboy3742 freakboy3742 added bug A crash or error in behavior. linux The issue relates Linux support. good first issue Is this your first time contributing? This could be a good place to start! labels May 6, 2024
@studioph
Copy link
Contributor

Taking a look at this

@studioph
Copy link
Contributor

studioph commented May 22, 2024

Have confirmed that it is not just Tab, but any key except enter triggers the beep. I suspect this is because the gtk_key_press_event handler in the TextInput implementation for GTK explicitly looks for enter/numpad enter and therefore is intercepting those before GTK does. Will work on seeing if updating the handler to capture all keypresses is the correct solution or if it's another GTK option somewhere

@studioph
Copy link
Contributor

Quick update to avoid ambiguity:
I am still investigating this on weekends, but have not made much progress. It's possible to suppress all further events by returning True from the handler, but while that does get rid of the beep, it also prevents the focus cycling. I've also come across what appears to be a global GTK setting to disable the bell, but that also is too heavy-handed. Still not sure why ENTER doesn't trigger the bell but my above theory hasn't panned out so far.

Setting the disable focus property on the textinput widget does still allow you to select and copy text with the mouse, but obviously not with the keyboard and it also skips during focus cycling so that's also not a solution.

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. good first issue Is this your first time contributing? This could be a good place to start! linux The issue relates Linux support.
Projects
None yet
Development

No branches or pull requests

2 participants