Fix file navigation typing issues

When you type in the navigation pane it just selects the quick search bar.
(party)
This commit is contained in:
afffsdd 2015-07-30 13:23:45 -04:00
parent 7740ae1e5e
commit 012c9e38d3

View file

@ -48,6 +48,7 @@ import the.bytecode.club.bytecodeviewer.*;
* *
* @author Konloch * @author Konloch
* @author WaterWolf * @author WaterWolf
* @author afffsdd
* *
*/ */
@ -64,6 +65,7 @@ public class FileNavigationPane extends VisibleComponent implements
MyTree tree = new MyTree(treeRoot); MyTree tree = new MyTree(treeRoot);
final String quickSearchText = "Quick file search (no file extension)"; final String quickSearchText = "Quick file search (no file extension)";
final JTextField quickSearch = new JTextField(quickSearchText); final JTextField quickSearch = new JTextField(quickSearchText);
boolean cancel = false;
public KeyAdapter search = new KeyAdapter() { public KeyAdapter search = new KeyAdapter() {
@Override @Override
@ -191,6 +193,10 @@ public class FileNavigationPane extends VisibleComponent implements
this.tree.addTreeSelectionListener(new TreeSelectionListener() { this.tree.addTreeSelectionListener(new TreeSelectionListener() {
@Override @Override
public void valueChanged(final TreeSelectionEvent arg0) { public void valueChanged(final TreeSelectionEvent arg0) {
if (cancel) {
cancel = false;
return;
}
openPath(arg0.getPath()); openPath(arg0.getPath());
} }
}); });
@ -203,11 +209,24 @@ public class FileNavigationPane extends VisibleComponent implements
MyTree tree = (MyTree) arg0.getSource(); MyTree tree = (MyTree) arg0.getSource();
openPath(tree.getSelectionPath()); openPath(tree.getSelectionPath());
} }
} else {
cancel = true;
} }
} }
@Override public void keyPressed(KeyEvent arg0) { } @Override
@Override public void keyTyped(KeyEvent arg0) { } public void keyTyped(KeyEvent e) {
quickSearch.grabFocus();
quickSearch.setText("" + e.getKeyChar()); // fuck
cancel = true;
}
@Override
public void keyPressed(KeyEvent e) {
quickSearch.grabFocus();
quickSearch.setText("" + e.getKeyChar()); // fuck
cancel = true;
}
}); });
quickSearch.addKeyListener(search); quickSearch.addKeyListener(search);