From 8da66c53eb788299904016bc7df2dfd67040bbdf Mon Sep 17 00:00:00 2001 From: gmungoc Date: Tue, 11 Jun 2019 13:57:48 +0100 Subject: [PATCH] JAL-3288 fixes for gain/lose focus --- src/jalview/gui/SplitFrame.java | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/jalview/gui/SplitFrame.java b/src/jalview/gui/SplitFrame.java index 44a97bc..25dedc5 100644 --- a/src/jalview/gui/SplitFrame.java +++ b/src/jalview/gui/SplitFrame.java @@ -42,6 +42,8 @@ import java.util.Map.Entry; import javax.swing.AbstractAction; import javax.swing.InputMap; import javax.swing.JComponent; +import javax.swing.JDesktopPane; +import javax.swing.JInternalFrame; import javax.swing.JMenuItem; import javax.swing.KeyStroke; import javax.swing.event.InternalFrameAdapter; @@ -790,11 +792,27 @@ public class SplitFrame extends GSplitFrame implements SplitContainerI } /** - * Override to do nothing - let the embedded AlignFrame's be the selected frame + * Override to do nothing if triggered from one of the child frames */ @Override public void setSelected(boolean selected) throws PropertyVetoException { - // no-op here fixes JAL-3288 (menus close immediately) + JDesktopPane desktopPane = getDesktopPane(); + JInternalFrame fr = desktopPane == null ? null + : desktopPane.getSelectedFrame(); + if (fr == getTopFrame() || fr == getBottomFrame()) + { + /* + * patch for JAL-3288 (deselecting top/bottom frame closes popup menu); + * it may be possible to remove this method in future + * if the underlying Java behaviour changes + */ + if (selected) + { + moveToFront(); + } + return; + } + super.setSelected(selected); } } -- 1.7.10.2