From 64f94357ebf6a7eb8cce14d6d3e62e4d159ddd78 Mon Sep 17 00:00:00 2001 From: tcofoegbu Date: Thu, 24 Sep 2015 15:56:25 +0100 Subject: [PATCH] JAL-1860 only allow enter key when valid selection are made and the veiew/ok button is enabled --- src/jalview/jbgui/GPDBSearchPanel.java | 5 ++++- src/jalview/jbgui/GStructureChooser.java | 12 +++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/jalview/jbgui/GPDBSearchPanel.java b/src/jalview/jbgui/GPDBSearchPanel.java index 7543b53..58ec25e 100644 --- a/src/jalview/jbgui/GPDBSearchPanel.java +++ b/src/jalview/jbgui/GPDBSearchPanel.java @@ -182,7 +182,10 @@ public abstract class GPDBSearchPanel extends JPanel btn_back_ActionPerformed(); break; case KeyEvent.VK_ENTER: // enter key - btn_ok_ActionPerformed(); + if (btn_ok.isEnabled()) + { + btn_ok_ActionPerformed(); + } break; case KeyEvent.VK_TAB: // tab key btn_back.requestFocus(); diff --git a/src/jalview/jbgui/GStructureChooser.java b/src/jalview/jbgui/GStructureChooser.java index 802cc0d..73a5615 100644 --- a/src/jalview/jbgui/GStructureChooser.java +++ b/src/jalview/jbgui/GStructureChooser.java @@ -235,10 +235,13 @@ public abstract class GStructureChooser extends JPanel implements mainFrame.dispose(); break; case KeyEvent.VK_ENTER: // enter key - ok_ActionPerformed(); + if (btn_view.isEnabled()) + { + ok_ActionPerformed(); + } break; case KeyEvent.VK_TAB: // tab key - btn_cancel.requestFocus(); + btn_view.requestFocus(); default: return; } @@ -270,7 +273,10 @@ public abstract class GStructureChooser extends JPanel implements mainFrame.dispose(); break; case KeyEvent.VK_ENTER: // enter key - ok_ActionPerformed(); + if (btn_view.isEnabled()) + { + ok_ActionPerformed(); + } break; case KeyEvent.VK_TAB: // tab key btn_cancel.requestFocus(); -- 1.7.10.2