-
Notifications
You must be signed in to change notification settings - Fork 290
Remove behavior from RangeSlider and SnapshotView control #1395
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
Conversation
controlsfx/src/main/java/impl/org/controlsfx/skin/RangeSliderSkin.java
Outdated
Show resolved
Hide resolved
controlsfx/src/main/java/impl/org/controlsfx/skin/RangeSliderSkin.java
Outdated
Show resolved
Hide resolved
controlsfx-samples/src/main/java/org/controlsfx/samples/HelloNotificationPane.java
Show resolved
Hide resolved
| // Fix for Issue #522: Prevent NotificationPane from receiving focus | ||
| ParentTraversalEngine engine = new ParentTraversalEngine(getSkinnable()); | ||
| ReflectionUtils.setTraversalEngine(control, engine); | ||
| engine.setOverriddenFocusTraversability(false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding a fix for these 3 lines has made me realized the importance of a Traversal Engine in JavaFX. Most of the heavy lifting was already done by @JonathanGiles in JDK-8091673. @Maxoudela @eugener Do you think its worth pursuing this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What was the purpose of these 3 lines?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can confirm what @abhinayagarwal has said about these lines. The issue-number #522 refers to BitBucket-Issues (no longer existant ...).
I also would appreciate if the TraversalEngine would be part of the public API. After all, the above lines are very hacky :-).
| actionsBar.opacityProperty().bind(transition); | ||
| actionsBar.focusedProperty().addListener((o, ov, hasFocus) -> { | ||
| if (!actionsBar.getButtons().isEmpty()) { | ||
| actionsBar.getButtons().get(0).requestFocus(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we care about thread-safety? If so, then it's possible that the button is removed between lines 175 and 176, resulting in a NullPointerException. Thoughts on an OOP alternative that upholds encapsulation? Maybe it's not possible, but something like:
actionBar.giveButtonFocus(OK_BUTTON); // OK_BUTTON constant = 0
That would eliminate the need for the conditional (in this method anyway). The actionsBar class would need a method like:
private final Object mutex = new Object();
public void giveButtonFocus( final int index ) {
final var buttons = getButtons();
// Don't allow multiple threads to enter this block. This would have to
// be sync'd on removal. Or use a synchronized collection.
synchronized( mutex ) {
// index is 0-based, size starts at 1 if not empty, so use >
if( buttons.size() > index ) {
buttons.get( index ).requestFocus();
}
}
}
That's then reusable, thread-safe, and will throw neither an NullPointerException nor an ArrayIndexOutOfBounds exception.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
JavaFX is a single threaded GUI framework i.e. all scene-graph activities are done on the JavaFX application thread. Therefore, activities like removing of nodes, focus etc. are all inherently executed synchronously.
|
Marking this PR as RFR |
Fixes #1073