JAL-1648 improvement on finder searchbox keyboard control - Enter to update search...
authortcofoegbu <tcnofoegbu@dundee.ac.uk>
Mon, 29 May 2017 14:12:17 +0000 (15:12 +0100)
committertcofoegbu <tcnofoegbu@dundee.ac.uk>
Mon, 29 May 2017 14:12:17 +0000 (15:12 +0100)
src/jalview/jbgui/GFinder.java

index 00b4fdc..c335b33 100755 (executable)
@@ -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)
   {
   }