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

lost_focus on a single_text_edit widget does not get called in several cases #2142

Open
Yvo68 opened this issue Oct 12, 2022 · 2 comments · May be fixed by #3247
Open

lost_focus on a single_text_edit widget does not get called in several cases #2142

Yvo68 opened this issue Oct 12, 2022 · 2 comments · May be fixed by #3247
Labels
bug Something is broken

Comments

@Yvo68
Copy link

Yvo68 commented Oct 12, 2022

Has been tested in master branch.

Describe the bug
lost_focus gets correctly called when clicking in an area without widget or when pressing ENTER but

lost_focus does not get called in the following cases:

  1. when focus is given to another widget (e.g. clicking on another single_text_edit)
  2. when tab is pressed (focus is given to the first widget of the panel while you would expect the next widget to get focus and the current widget to lose focus

Case 1:
Click on a single_text_edit to get focus
Click on a second single_text_edit --> you get focus on the second widget without lost_focus getting called on the first one

Case 2:
Click on a single_text_edit to get focus
Press tab --> the first widget gets focus without lost_focus being called on our focused widget
Press tab until you reach the correct widget --> the lost_focus gets correctly called when leaving the considered widget

Expected behavior
a) lost_focus should be called when focus is given to another widget
b) Pressing TAB for the first time should move to the widget just after the currently widget under focus (and call lost_focus)

**Desktop **

  • OS: MACOS
  • Browser Chrome
  • Version 105.0.5195.125
@Yvo68 Yvo68 added the bug Something is broken label Oct 12, 2022
@Yvo68
Copy link
Author

Yvo68 commented Oct 12, 2022

Sorry (my bad), seems the case 2 ("TAB") has been fixed between 0.19.0 and master branch.
The bug on case 1 is still present in master branch.

@phire
Copy link

phire commented Aug 13, 2023

I've run into this myself (case 1), and it's still present on the latest master.

Digging a bit deeper, the problem is actually dependant on the ordering. If you click from one TextEdit field to another created later, then the lost_focus() event is missed. But if you click to one created previously, then lost_focus()` works as expected.

phire added a commit to phire/egui that referenced this issue Aug 13, 2023
Otherwise focus.id will be inconsistance thoughout the frame, which
causes issues with gained_focus and lost_focus.

Fixes emilk#2142
@phire phire linked a pull request Aug 13, 2023 that will close this issue
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

Successfully merging a pull request may close this issue.

2 participants