From 4f5d2da2c2b81e7d2d0481873194c8e58eee99c3 Mon Sep 17 00:00:00 2001 From: Sol Date: Fri, 15 May 2015 14:42:03 +0000 Subject: [PATCH] - Fix issue where End Turn is focused in certain cases (like using targeting through the dev controls) --- .../src/main/java/forge/screens/match/CMatchUI.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/forge-gui-desktop/src/main/java/forge/screens/match/CMatchUI.java b/forge-gui-desktop/src/main/java/forge/screens/match/CMatchUI.java index 43f010466e7..dd1f9233729 100644 --- a/forge-gui-desktop/src/main/java/forge/screens/match/CMatchUI.java +++ b/forge-gui-desktop/src/main/java/forge/screens/match/CMatchUI.java @@ -556,15 +556,24 @@ public final class CMatchUI final FButton btn1 = view.getBtnOK(), btn2 = view.getBtnCancel(); btn1.setText(label1); btn2.setText(label2); + + // Remove focusable so the right button grabs focus properly + btn1.setFocusable(false); + btn2.setFocusable(false); + btn1.setEnabled(enable1); btn2.setEnabled(enable2); final FButton toFocus = enable1 && focus1 ? btn1 : (enable2 ? btn2 : null); // ensure we don't steal focus from an overlay - if (toFocus != null && !SOverlayUtils.overlayHasFocus()) { + if (toFocus != null) { FThreads.invokeInEdtLater(new Runnable() { @Override public final void run() { - toFocus.requestFocusInWindow(); + btn1.setFocusable(true); + btn2.setFocusable(true); + if (!SOverlayUtils.overlayHasFocus()) { + toFocus.requestFocus(); + } } }); }