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

Entry doesn't lose focus when clicking on button elsewhere #5107

Open
2 tasks done
antongumenov opened this issue Sep 2, 2024 · 3 comments
Open
2 tasks done

Entry doesn't lose focus when clicking on button elsewhere #5107

antongumenov opened this issue Sep 2, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@antongumenov
Copy link

antongumenov commented Sep 2, 2024

Checklist

  • I have searched the issue tracker for open issues that relate to the same problem, before opening a new one.
  • This issue only relates to a single bug. I will open new issues for any other problems.

Describe the bug

I have button and entry.
When i tap any button, entry do not loose focus.
When i tap any label, entry loose focus.
If i use entry.FocusLost() in button handler or entry.onSubmitted, entry loose focus, but if i tap back into entry, it can't get focus. I think it's a bug.
If i tap on some label, and then into entry, it get focus.

How to reproduce

You can clone and run:
https://github.com/antongumenov/tong_simulator.git

Or look code here:
https://github.com/antongumenov/tong_simulator/blob/main/internal/view/main_screen_components/dump_level_widget.go

Screenshots

No response

Example code

entry.OnSubmitted = func(s string) {
	if s != "" {
		val, _ := strconv.ParseInt(s, 10, 64)
		e.ctrl.SetDumpLevel(val)
	}
	entry.FocusLost()
}
btn := widget.NewButton("SET MAX TORQUE", func() {
	if entry.Text != "" {
		val, _ := strconv.ParseInt(entry.Text, 10, 64)
		e.ctrl.SetDumpLevel(val)
	}
	entry.FocusLost()
})

Fyne version

v2.5.1

Go compiler version

go1.23.0 linux/amd64

Operating system and version

Arch Linux

Additional Information

No response

@antongumenov antongumenov added the unverified A bug that has been reported but not verified label Sep 2, 2024
@dweymouth dweymouth added bug Something isn't working and removed unverified A bug that has been reported but not verified labels Sep 2, 2024
@dweymouth dweymouth added this to the E fixes (v2.5.x) milestone Sep 2, 2024
@dweymouth
Copy link
Contributor

You are typically not supposed to call entry.FocusLost yourself - Fyne calls that when it loses focus to tell the entry to update its styling. There is a bug here that Entry doesn't lose focus automatically when you tap on a button - just confirmed.

@dweymouth dweymouth changed the title Entry don't get focus on tap after entry.FocusLost() Entry doesn't lose focus when clicking on button elsewhere Sep 2, 2024
@antongumenov
Copy link
Author

The problem is not only that entry don't loose focus. Entry can't get focus on tap after entry.FocusLost() until i tap any another widget, for example some lable. Just to clarify. Maybe it's important.

@andydotxyz
Copy link
Member

As Drew says that is an internal callback as a result of losing focus. If you call it directly the entry still has focus but looks like it doesn't (because you told it to). So tapping elsewhere actually unfocused it. Just tapping in entry won't do anything because it still has focus.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants