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

widget: make Button trigger unfocus when tapped. #5152

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

pierrec
Copy link

@pierrec pierrec commented Sep 18, 2024

Fixes #5107.

Description:

Previously, widget.Button did not grab the focus when tapped, resulting in any focused widget on the canvas remaining focused. Now it does gab the focus and then releases it as this should be transient for a button.

Fixes #5107.

Checklist:

  • Tests included.
  • Lint and formatter run with no errors.
  • Tests all pass.
    (besides language related ones)

@andydotxyz
Copy link
Member

That's not how other widgets behave. If someone wants to switch to keyboard handling then it should start from the last item they interacted with.

This may relate to a request for "remember potential focus in case keyboard controls are used" which would be a behaviour change and would have to apply to most widgets (not Entry ;) ) in a major release like 2.6.

@pierrec
Copy link
Author

pierrec commented Sep 18, 2024

That's not how other widgets behave. If someone wants to switch to keyboard handling then it should start from the last item they interacted with.

This may relate to a request for "remember potential focus in case keyboard controls are used" which would be a behaviour change and would have to apply to most widgets (not Entry ;) ) in a major release like 2.6.

So you are saying that clicking the button should not unfocus anything?

@andydotxyz
Copy link
Member

That's not what I am saying.
To be consistent with other widgets when you interact with a widget it would take focus, but it would not immediately lose focus.

@pierrec
Copy link
Author

pierrec commented Sep 20, 2024

I see. The reason I removed focus was that otherwise the button appears in focus mode (blue background with the default theme) once clicked. Is this expected?

@andydotxyz
Copy link
Member

That is how other widgets behave isn't it?
I agree it doesn't look quite right - which is why I mentioned a discussion that had happened regarding "potentially focused" or "invisible focus" in case the keyboard handing is invoked.

@Jacalz
Copy link
Member

Jacalz commented Sep 25, 2024

I think this might be a sensible change. It seems like many applications on my computer at least do unfocus when you press a button.

@andydotxyz
Copy link
Member

Rather than considering just the visual state we need to consider the context. When another toolkit "unfocuses" the button after tapping with a mouse what happens if you hit space or enter? What happens if you hit tab?

In my experience the item still has focus it just doesn't indicate that for this situation.

@pierrec
Copy link
Author

pierrec commented Sep 25, 2024

So would only removing the visuals of the focus for a clicked button but keeping its focus be fine?

@andydotxyz
Copy link
Member

So would only removing the visuals of the focus for a clicked button but keeping its focus be fine?

Sorry I missed this.
I suspect that your approach would be OK - but bear in mind it will still need the visual when using keyboard interactions.

I think that is the thing we need to balance with more than just button - focusing something because it's interacted but not necessarily highlighting it until keyboard interaction?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants