From: gmungoc Date: Tue, 11 Jun 2019 12:57:48 +0000 (+0100) Subject: JAL-3288 fixes for gain/lose focus X-Git-Tag: Release_2_11_0~7^2~7 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=8da66c53eb788299904016bc7df2dfd67040bbdf;p=jalview.git JAL-3288 fixes for gain/lose focus --- 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); } }