Skip to content

Commit

Permalink
Navigate panels with tab and shift + tab
Browse files Browse the repository at this point in the history
  • Loading branch information
Inaba Kazuhiro committed Oct 29, 2016
1 parent a117831 commit a2d3dd3
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/main/java/seedu/taskman/ui/MainWindow.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
package seedu.taskman.ui;

import java.util.ArrayList;

import javafx.fxml.FXML;
import javafx.scene.Node;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.ListView;
import javafx.scene.control.MenuItem;
import javafx.scene.input.KeyCombination;
import javafx.scene.layout.AnchorPane;
Expand Down Expand Up @@ -119,6 +123,7 @@ void fillInnerParts() {
resultDisplay = ResultDisplay.load(primaryStage, getResultDisplayPlaceholder());
statusBarFooter = StatusBarFooter.load(primaryStage, getStatusbarPlaceholder(), config.getTaskManFilePath());
commandBox = CommandBox.load(primaryStage, getCommandBoxPlaceholder(), resultDisplay, logic);
configureFocus();
}

private AnchorPane getCommandBoxPlaceholder() {
Expand Down Expand Up @@ -232,6 +237,31 @@ public void show() {
private void handleExit() {
raise(new ExitAppRequestEvent());
}

private void configureFocus() {
ArrayList<Node> nodes = getAllNodes();
for (Node node : nodes) {
if (node.getClass().equals(ListView.class)) {
node.setFocusTraversable(true);
} else {
node.setFocusTraversable(false);
}
}
}

private ArrayList<Node> getAllNodes() {
ArrayList<Node> nodes = new ArrayList<Node>();
addAllDescendents(rootLayout, nodes);
return nodes;
}

private void addAllDescendents(Parent parent, ArrayList<Node> nodes) {
for (Node node : parent.getChildrenUnmodifiable()) {
nodes.add(node);
if (node instanceof Parent)
addAllDescendents((Parent)node, nodes);
}
}


}

0 comments on commit a2d3dd3

Please sign in to comment.