egui icon indicating copy to clipboard operation
egui copied to clipboard

Single line TextEdit ignores input after repeated calls to request_focus()

Open rustingcode opened this issue 1 year ago • 2 comments

Describe the bug Attempting to call request_focus() on a single line text edit every time it loses focus will eventually cause the TextEdit to ignore any further key presses.

This happens on native build (egui 0.29) for Linux with eframe. Have not tested on MacOS or Windows. Does not occur on webassembly build (tested in firefox)

To Reproduce Steps to reproduce the behavior:

  1. Checkout the latest eframe_template (using egui 0.29)
  2. Replace this line: ui.text_edit_singleline(&mut self.label); with this block (the point being to restore focus on the input field every time after pressing enter): let response = ui.text_edit_singleline(&mut self.label); if !response.has_focus() { response.request_focus(); }
  3. Run the demo and type something in the test box and hit enter
  4. Notice that focus was restored to the text box
  5. Type some more characters, then hold down the enter key for a few seconds
  6. Try to type some more characters
  7. Notice that the text field now ignores all further input (if problem doesn't yet occur, repeat step 5 - this is reproducible every time on my system after a few attempts at most)

Expected behavior Regardless of how many times the text box loses focus due to pressing enter, the focus should still be restored and the text box should accept further input.

Desktop (please complete the following information): Tested on Linux Mint with egui 0.29

Problem does not occur on wasm build (tested in Firefox)

rustingcode avatar Sep 29 '24 22:09 rustingcode

Please check if this was solved by

  • https://github.com/emilk/egui/pull/5188

emilk avatar Sep 30 '24 11:09 emilk

Please check if this was solved by

* [Linux: Disable IME to fix backspace/arrow keys #5188](https://github.com/emilk/egui/pull/5188)

I tested again with the fix for #5188 but that update doesn't resolve this issue.

rustingcode avatar Oct 03 '24 16:10 rustingcode

Still having this bug. sometimes it works, but most times it doesn't

rubbieKelvin avatar Aug 08 '25 13:08 rubbieKelvin