From: tcofoegbu Date: Mon, 29 May 2017 14:12:17 +0000 (+0100) Subject: JAL-1648 improvement on finder searchbox keyboard control - Enter to update search... X-Git-Tag: Release_2_10_2~3^2~45^2 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=1ed483c88a51302e76fcba18f685497b6307f1b3;p=jalview.git JAL-1648 improvement on finder searchbox keyboard control - Enter to update search box if popup is displayed otherwise perform find next action --- diff --git a/src/jalview/jbgui/GFinder.java b/src/jalview/jbgui/GFinder.java index 00b4fdc..c335b33 100755 --- a/src/jalview/jbgui/GFinder.java +++ b/src/jalview/jbgui/GFinder.java @@ -33,6 +33,7 @@ import java.awt.Font; import java.awt.GridLayout; import java.awt.Insets; import java.awt.event.ActionEvent; +import java.awt.event.KeyEvent; import javax.swing.JButton; import javax.swing.JCheckBox; @@ -142,7 +143,15 @@ public class GFinder extends JPanel textfield_caretUpdate(e); } }); - + searchBox.getEditor().getEditorComponent() + .addKeyListener(new java.awt.event.KeyAdapter() + { + @Override + public void keyPressed(KeyEvent e) + { + textfield_keyPressed(e); + } + }); mainBorderLayout.setHgap(5); mainBorderLayout.setVgap(5); jPanel4.setLayout(borderLayout2); @@ -176,6 +185,18 @@ public class GFinder extends JPanel jPanel4.add(optionsPanel, java.awt.BorderLayout.WEST); } + protected void textfield_keyPressed(KeyEvent e) + { + if (e.getKeyCode() == KeyEvent.VK_ENTER) + { + if (!searchBox.isPopupVisible()) + { + e.consume(); + findNext_actionPerformed(null); + } + } + } + protected void findNext_actionPerformed(ActionEvent e) { }