mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 20:58:03 +00:00
move some focus stuff into GUI thread to try to fix crash
This commit is contained in:
@@ -566,32 +566,37 @@ public final class CMatchUI
|
|||||||
|
|
||||||
final FButton toFocus = enable1 && focus1 ? btn1 : (enable2 ? btn2 : null);
|
final FButton toFocus = enable1 && focus1 ? btn1 : (enable2 ? btn2 : null);
|
||||||
|
|
||||||
|
//pfps This seems wrong so I've commented it out for now and put a replacement in the runnable
|
||||||
// Remove focusable so the right button grabs focus properly
|
// Remove focusable so the right button grabs focus properly
|
||||||
//pfps This seems wrong so I've commented it out for now and replaced it
|
|
||||||
//if (toFocus == btn2)
|
//if (toFocus == btn2)
|
||||||
//btn1.setFocusable(false);
|
//btn1.setFocusable(false);
|
||||||
//else if (toFocus == btn1)
|
//else if (toFocus == btn1)
|
||||||
//btn2.setFocusable(false);
|
//btn2.setFocusable(false);
|
||||||
btn2.setFocusable(enable2); // order may matter here
|
|
||||||
btn1.setFocusable(enable1);
|
|
||||||
btn2.setEnabled(enable2);
|
|
||||||
btn1.setEnabled(enable1);
|
|
||||||
|
|
||||||
// ensure we don't steal focus from an overlay
|
btn1.setEnabled(enable1);
|
||||||
if (toFocus != null) {
|
btn2.setEnabled(enable2);
|
||||||
|
|
||||||
final Runnable focusRoutine = new Runnable() {
|
final Runnable focusRoutine = new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public final void run() {
|
public final void run() {
|
||||||
|
// The only button that is focusable is the enabled default button
|
||||||
|
// This prevents the user from somehow focusing on on some other button
|
||||||
|
// and then using the keyboard to try to select it
|
||||||
|
btn1.setFocusable(enable1 && focus1 );
|
||||||
|
btn2.setFocusable(enable2 && !focus1);
|
||||||
|
// ensure we don't steal focus from an overlay
|
||||||
|
if (toFocus != null) {
|
||||||
toFocus.requestFocus(); // focus here even if another window has focus - shouldn't have to do it this way but some popups grab window focus
|
toFocus.requestFocus(); // focus here even if another window has focus - shouldn't have to do it this way but some popups grab window focus
|
||||||
}
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if (FThreads.isGuiThread()) { // run this now whether in EDT or not so that it doesn't clobber later stuff
|
if (FThreads.isGuiThread()) { // run this now whether in EDT or not so that it doesn't clobber later stuff
|
||||||
FThreads.invokeInEdtNowOrLater(focusRoutine);
|
FThreads.invokeInEdtNowOrLater(focusRoutine);
|
||||||
} else {
|
} else {
|
||||||
FThreads.invokeInEdtAndWait(focusRoutine);
|
FThreads.invokeInEdtAndWait(focusRoutine);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void flashIncorrectAction() {
|
public void flashIncorrectAction() {
|
||||||
|
|||||||
Reference in New Issue
Block a user