Skip to content

Commit

Permalink
CSSTUDIO-1986 Allow selection of widgets in the Widget Tree using the…
Browse files Browse the repository at this point in the history
… arrow keys when the Widget Tree has the focus.
  • Loading branch information
abrahamwolk committed Jul 20, 2023
1 parent 785e320 commit 58fa25b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
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 ->
{
event.consume();
tracker.requestFocus();
Expand Down

0 comments on commit 58fa25b

Please sign in to comment.