- break;
- case BACK:
- String warning = content.getExitWarning();
- if (warning != null) {
- if (answer == null) {
- setQuestion(key, warning);
- } else {
- setMessage(null, false);
- if (answer.equalsIgnoreCase("y")) {
- popContent();
- }
- }
- } else {
+ return handled;
+ }
+
+ /**
+ * Handle the input in case of "normal" (not "ask for answer") mode.
+ *
+ * @param key
+ * the key that was pressed
+ * @param answer
+ * the answer given for this key
+ *
+ * @return if the window handled the input
+ */
+ private void handleAction(KeyAction action, String answer) {
+ MainContent content = getContent();
+
+ Card card = action.getCard();
+ Contact contact = action.getContact();
+ Data data = action.getData();
+
+ switch (action.getMode()) {
+ case MOVE:
+ int x = 0;
+ int y = 0;
+
+ if (action.getKey().getKeyType() == KeyType.ArrowUp)
+ x = -1;
+ if (action.getKey().getKeyType() == KeyType.ArrowDown)
+ x = 1;
+ if (action.getKey().getKeyType() == KeyType.ArrowLeft)
+ y = -1;
+ if (action.getKey().getKeyType() == KeyType.ArrowRight)
+ y = 1;
+
+ if (content != null) {
+ String err = content.move(x, y);
+ if (err != null)
+ setMessage(err, true);
+ }
+
+ break;
+ // mode with windows:
+ case CONTACT_LIST:
+ if (card != null) {
+ pushContent(new ContactList(card));
+ }
+ break;
+ case CONTACT_DETAILS:
+ if (contact != null) {
+ pushContent(new ContactDetailsRaw(contact));
+ }
+ break;
+ // mode interpreted by MainWindow:
+ case HELP:
+ // TODO
+ // setMessage("Help! I need somebody! Help!", false);
+ if (answer == null) {
+ setQuestion(action, "Test question?", "[initial]");
+ } else {
+ setMessage("You answered: " + answer, false);
+ }
+
+ break;
+ case BACK:
+ String warning = content.getExitWarning();
+ if (warning != null) {
+ if (answer == null) {
+ setQuestion(action, warning);
+ } else {
+ setMessage(null, false);
+ if (answer.equalsIgnoreCase("y")) {