Skip to content

Commit 90fc110

Browse files
committed
added browser-like forward and back behavior to side mouse buttons
1 parent 11eb814 commit 90fc110

2 files changed

Lines changed: 22 additions & 0 deletions

File tree

app/logbook/olog/ui/src/main/java/org/phoebus/logbook/olog/ui/LogEntryTable.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,12 @@
22

33
import javafx.collections.FXCollections;
44
import javafx.collections.ObservableList;
5+
import javafx.event.EventDispatcher;
56
import javafx.fxml.FXMLLoader;
7+
import javafx.scene.Node;
68
import javafx.scene.control.Alert;
9+
import javafx.scene.input.MouseButton;
10+
import javafx.scene.input.MouseEvent;
711
import org.phoebus.framework.nls.NLS;
812
import org.phoebus.framework.persistence.Memento;
913
import org.phoebus.framework.spi.AppDescriptor;
@@ -105,6 +109,19 @@ public LogEntryTable(final LogEntryTableApp app) {
105109
DockItem tab = new DockItem(this, loader.getRoot());
106110
tab.addClosedNotification(()-> controller.shutdown());
107111
DockPane.getActiveDockPane().addTab(tab);
112+
113+
Node node = loader.getRoot();
114+
EventDispatcher original = node.getScene().getEventDispatcher();
115+
node.getScene().setEventDispatcher((event, tail) -> {
116+
if (event instanceof MouseEvent me && me.getEventType() == MouseEvent.MOUSE_PRESSED) {
117+
if(me.getButton() == MouseButton.FORWARD){
118+
goBackAndGoForwardActions.goForward();
119+
} else if (me.getButton() == MouseButton.BACK){
120+
goBackAndGoForwardActions.goBack();
121+
}
122+
}
123+
return original.dispatchEvent(event, tail);
124+
});
108125
} catch (IOException e) {
109126
log.log(Level.WARNING, "Cannot load UI", e);
110127
}

app/logbook/ui/src/main/java/org/phoebus/logbook/ui/LogEntryTableViewController.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,11 @@ public void initialize() {
133133
timeOwnerCol.setCellValueFactory(col -> new SimpleObjectProperty<>(col.getValue()));
134134
timeOwnerCol.setCellFactory(col -> {
135135
final GridPane pane = new GridPane();
136+
137+
// pane.setOnMousePressed(event -> {
138+
// System.out.println("Button: " + event.getButton());
139+
// });
140+
136141
final Label timeText = new Label();
137142
timeText.setStyle("-fx-font-weight: bold");
138143
final Label ownerText = new Label();

0 commit comments

Comments
 (0)