Fix so Ok button in DualListBox dialog receives focus as soon as it's been enabled so spacebar will activate it

This commit is contained in:
drdev
2013-12-04 03:44:32 +00:00
parent 3c0bfa7843
commit aa48e9cacc
2 changed files with 6 additions and 5 deletions

View File

@@ -598,7 +598,6 @@ public class PlayerControllerHuman extends PlayerController {
return GuiDialog.confirm(replacementEffect.getHostCard(), question);
}
@Override
public List<Card> getCardsToMulligan(boolean isCommander, Player firstPlayer) {
final InputConfirmMulligan inp = new InputConfirmMulligan(player, firstPlayer, isCommander);
@@ -715,7 +714,6 @@ public class PlayerControllerHuman extends PlayerController {
return GuiDialog.confirm(sa.getSourceCard(), question, labels);
}
@Override
public boolean chooseFlipResult(SpellAbility sa, Player flipper, boolean[] results, boolean call) {
String[] labelsSrc = call ? new String[]{"heads", "tails"} : new String[]{"win the flip", "lose the flip"};
@@ -773,7 +771,6 @@ public class PlayerControllerHuman extends PlayerController {
GuiDialog.message(message, sa.getSourceCard().getName());
}
// These are not much related to PlayerController
private String formatNotificationMessage(SpellAbility sa, GameObject target, String value) {
if (sa.getApi() == null) {
@@ -831,7 +828,7 @@ public class PlayerControllerHuman extends PlayerController {
public List<String> chooseColors(String message, SpellAbility sa, int min, int max, List<String> options) {
return GuiChoose.getChoices(message, min, max, options);
}
@Override
public String chooseSingleColor(ImmutableList<String> names) {
return GuiChoose.one("Choose a color:", names);

View File

@@ -92,6 +92,9 @@ public class DualListBox<T> extends FPanel {
clearSourceSelected();
sourceList.validate();
_setButtonState();
if (okButton.isEnabled()) {
okButton.requestFocusInWindow();
}
}
};
@@ -217,7 +220,7 @@ public class DualListBox<T> extends FPanel {
}
}
private void _handleListKey (KeyEvent e, Runnable onSpace, FList<T> arrowFocusTarget) {
private void _handleListKey(KeyEvent e, Runnable onSpace, FList<T> arrowFocusTarget) {
switch (e.getKeyCode()) {
case KeyEvent.VK_SPACE:
onSpace.run();
@@ -409,6 +412,7 @@ public class DualListBox<T> extends FPanel {
addDestinationElements(sourceListModel);
clearSourceListModel();
_setButtonState();
okButton.requestFocusInWindow();
}
private void _removeAll() {