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

CSSTUDIO-1986 Prevent selection of widgets in the Widget Tree using the arrow keys. #2736

Merged
merged 3 commits into from
Jul 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,11 @@ private void closeInlineEditor()
inline_editor = null;
}

private boolean requestFocusIsDisabled = false;
public void setDisableRequestFocus(boolean requestFocusIsDisabled) {
this.requestFocusIsDisabled = requestFocusIsDisabled;
}

/** Locate widgets that would be 'clicked' by a mouse event's location */
private class ClickWidgets extends RecursiveTask<Boolean>
{
Expand Down Expand Up @@ -635,9 +640,10 @@ public void setSelectedWidgets(final List<Widget> widgets)

bindToWidgets();

// Get focus to allow use of arrow keys
Platform.runLater(() -> tracker.requestFocus());

if (!requestFocusIsDisabled) {
// Get focus to allow use of arrow keys
Platform.runLater(() -> tracker.requestFocus());
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -331,9 +331,11 @@ private void bindSelections()
: wot.getTab().getWidget();
if (! widgets.contains(widget))
widgets.add(widget);
};
}
logger.log(Level.FINE, "Selected in tree: {0}", widgets);
editor.getSelectedWidgetUITracker().setDisableRequestFocus(true);
editor.getWidgetSelectionHandler().setSelection(widgets);
editor.getSelectedWidgetUITracker().setDisableRequestFocus(false);
}
finally
{
Expand Down
2 changes: 1 addition & 1 deletion core/ui/src/main/java/org/phoebus/ui/javafx/Tracker.java
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ void hookEvents()
// Keep the keyboard focus to actually get key events.
// The RTImagePlot will also listen to mouse moves and try to keep the focus,
// so the active tracker uses an event filter to have higher priority
tracker.addEventFilter(MouseEvent.MOUSE_MOVED, event ->
tracker.addEventFilter(MouseEvent.MOUSE_CLICKED, event ->
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change I am not 100% sure about. Previously (i.e., with MouseEvent.MOUSE_MOVED), the selected items in the Display Editor were given focus whenever the mouse hovered over them. I found this behavior counter-intuitive, and with this change, they are instead given the focus by clicking on the selection using the mouse.

{
event.consume();
tracker.requestFocus();
Expand Down
Loading