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

TextEdit does not "consume" keypresses it reacts to, leading to both the widget and app reacting to the same keypress #5609

Open
barries opened this issue Jan 15, 2025 · 0 comments
Labels
bug Something is broken

Comments

@barries
Copy link

barries commented Jan 15, 2025

Describe the bug
TextEdit (and maybe other widgets) reacts to Esc to defocus. If the application checks ctx.input() and !wants_keyboard_input() to use Escape as a shortcut for, e.g. a Cancel button, then when a TextEdit is focused and the user hits Esc to defocus it (hoping to revert their edits), then the TextEdit correctly defocuses, and clears the wants_keyboard_input() flag, which leads the app to incorrectly react to the Esc, so Esc double-acts by (a) cancelling focus and (b) doing whatever Cancel does.

To Reproduce
Steps to reproduce the behavior:

  1. Create an app with a TextEdit that does something ctx.input() for Escape to be released when !wants_keyboard_input().
  2. Edit the text in the TextEdit
  3. Press Esc
  4. Observe the TextEdit defocuses, and that wants_keyboard_input() goes false leading the app to also detect an Escape release

Expected behavior
The TextEdit and other widgets (for example, modals) should "consume" the events they process so that code later in the frame does not also react to those events.

egui: 0.30

@barries barries added the bug Something is broken label Jan 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something is broken
Projects
None yet
Development

No branches or pull requests

1 participant