mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 12:18:00 +00:00
Ensure first ability selected in menu by default
This commit is contained in:
@@ -11,6 +11,9 @@ import java.util.Map;
|
|||||||
import javax.swing.JOptionPane;
|
import javax.swing.JOptionPane;
|
||||||
import javax.swing.JPopupMenu;
|
import javax.swing.JPopupMenu;
|
||||||
import javax.swing.KeyStroke;
|
import javax.swing.KeyStroke;
|
||||||
|
import javax.swing.MenuElement;
|
||||||
|
import javax.swing.MenuSelectionManager;
|
||||||
|
import javax.swing.SwingUtilities;
|
||||||
|
|
||||||
import org.apache.commons.lang.math.IntRange;
|
import org.apache.commons.lang.math.IntRange;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
@@ -136,6 +139,11 @@ public class PlayerControllerHuman extends PlayerController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (hasEnabled) { //only show menu if at least one ability can be played
|
if (hasEnabled) { //only show menu if at least one ability can be played
|
||||||
|
SwingUtilities.invokeLater(new Runnable() { //use invoke later to ensure first ability selected by default
|
||||||
|
public void run() {
|
||||||
|
MenuSelectionManager.defaultManager().setSelectedPath(new MenuElement[]{menu, menu.getSubElements()[0]});
|
||||||
|
}
|
||||||
|
});
|
||||||
menu.show(triggerEvent.getComponent(), triggerEvent.getX(), triggerEvent.getY());
|
menu.show(triggerEvent.getComponent(), triggerEvent.getX(), triggerEvent.getY());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user