8379942: Some non focus-traversable Controls do not request focus when clicking on it#2106
8379942: Some non focus-traversable Controls do not request focus when clicking on it#2106Maran23 wants to merge 3 commits into
Conversation
| * | ||
| * @return boolean indicating whether the scene is quiescent | ||
| */ | ||
| boolean isQuiescent() { |
|
👋 Welcome back mhanl! A progress list of the required criteria for merging this PR into |
|
❗ This change is not yet ready to be integrated. |
Webrevs
|
| if (s != null && | ||
| (this == s.getFocusOwner() || isFocusTraversable())) { | ||
| s.setFocusDirty(true); | ||
| if (s != null && this == s.getFocusOwner()) { |
There was a problem hiding this comment.
Thinking about this twice, I will revert this change here.
The focus traversable is not checked in the focus dirty code:
jfx/modules/javafx.graphics/src/main/java/javafx/scene/Scene.java
Lines 2637 to 2651 in 11d65f1
But the Scene.this.focusInitial(); might change the initial focused node when the focus traversable changed from false to true.
So the scenario could be:
- Nothing is the focus owner
- A
Nodeis set to focus traversabletrue(fromfalse) - Now this code runs and
focusInitial()is called to traverse to the now traversableNode
|
/reviewers 2 |
|
This exposed a problem inside |
ScrollBar should not request focus, as many other Controls do not do that when there is no benefit.
Yes, the semantics of I don't see a whole lot of value of having a control accept focus with a mouse click, but not via keyboard navigation. What's the use case here? I would imagine that if a control is focusable with a mouse click, it should also be focusable with keyboard navigation. However, I see quite a bit of value of having a control not accept focus at all, but still be fully functional otherwise. For example, consider a "Copy" or "Paste" button that act on the currently focused control. It's clear that such a button can never accept focus, as that would break the intended function. With your proposed change, a button will always accept focus on click. This subtly breaks the cut/copy/paste buttons of I see two ways forward here:
I don't think we can do what you propose and force a control to always accept focus when clicked, but not accept it when keyboard-traversed. That would be a functional regression for applications that rely on the non-stealing focus behavior of buttons. In any case, we need to discuss this on the mailing list since it affects core semantics of JavaFX. |
This is a very interesting usecase.
Yes, other frameworks usually differ between keyboard and mouse focus.
This seems like a good way. The last time I wrote about those findings, I got no answer (Me and John thought this was a bug). |
+1, agree. |
|
@Maran23 This pull request has been inactive for more than 8 weeks and will be automatically closed if another 8 weeks passes without any activity. To avoid this, simply issue a |
|
closing because this is something we probably need to do after we settled with the focus changes. |
As also discussed back then in the mailing list, there are weird issues around gaining focus when a
Controlis not focus traversable but got a click event.requestFocus()when they are not focus traversable and receive a mouse clickControlwill request focus, while another one will notrequestFocus()always worksIt seems like there is a misconception between beeing not focus traversable and not requesting focus. The focus traversable property should only affect keyboard navigation really. A mouse click should always request a focus.
Check the Ticket for a reproducer with all
Controls and a short list which Controls do not behave (and which do).This PR removes the pattern that was wrongly used in some
Controls.From:
To:
Progress
Issue
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jfx.git pull/2106/head:pull/2106$ git checkout pull/2106Update a local copy of the PR:
$ git checkout pull/2106$ git pull https://git.openjdk.org/jfx.git pull/2106/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 2106View PR using the GUI difftool:
$ git pr show -t 2106Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jfx/pull/2106.diff
Using Webrev
Link to Webrev Comment