Support using Escape to cancel card selection

This commit is contained in:
drdev
2014-05-03 17:21:11 +00:00
parent 774dafc813
commit 3bfc8a926e
2 changed files with 17 additions and 13 deletions

View File

@@ -55,7 +55,7 @@ public class InputSelectCard {
} }
return; //don't select already selected card return; //don't select already selected card
} }
CardOptionsList.hide(); //hide previous card options list before showing a new one hide(); //hide previous card options list before showing a new one
} }
lastSelectTime = now; lastSelectTime = now;
@@ -94,6 +94,18 @@ public class InputSelectCard {
} }
} }
public static boolean hide() {
if (activeList == null) { return false; }
FControl.getView().remove(activeList);
FControl.getView().remove(CardOptionsList.backdrop);
activeList = null;
zoomPressed = false;
detailsPressed = false;
ownerPressed = false;
pannedOverOptions = false;
return true;
}
public static boolean handlePan(CardAreaPanel cardPanel, float x, float y, boolean isPanStop) { public static boolean handlePan(CardAreaPanel cardPanel, float x, float y, boolean isPanStop) {
if (simulatedListPress) { if (simulatedListPress) {
//prevent pressed item getting stuck //prevent pressed item getting stuck
@@ -213,17 +225,6 @@ public class InputSelectCard {
owner = owner0; owner = owner0;
} }
public static void hide() {
if (activeList == null) { return; }
FControl.getView().remove(activeList);
FControl.getView().remove(backdrop);
activeList = null;
zoomPressed = false;
detailsPressed = false;
ownerPressed = false;
pannedOverOptions = false;
}
@Override @Override
protected void drawBackground(Graphics g) { protected void drawBackground(Graphics g) {
g.fillRect(BACK_COLOR, 0, 0, getWidth(), getHeight()); g.fillRect(BACK_COLOR, 0, 0, getWidth(), getHeight());

View File

@@ -176,7 +176,10 @@ public class MatchScreen extends FScreen {
} }
return prompt.getBtnCancel().trigger(); //trigger Cancel if can't trigger OK return prompt.getBtnCancel().trigger(); //trigger Cancel if can't trigger OK
case Keys.ESCAPE: case Keys.ESCAPE:
return prompt.getBtnCancel().trigger(); //trigger Cancel on Escape if (InputSelectCard.hide()) { //hide card selection if one active on Escape
return true;
}
return prompt.getBtnCancel().trigger(); //otherwise trigger Cancel
} }
return super.keyDown(keyCode); return super.keyDown(keyCode);
} }