Esempio n. 1
0
  public void keyPressed(int key) {

    int actionOld;
    String keyName;

    if (key == 0 || key == keyBindings.getKeyForAction(actionToBind)) {

      display.setCurrent(this);

    } else if (keyBindings.isBound(key)) {

      selectedKey = key;

      actionOld = keyBindings.getActionForKey(key);
      keyName = screenKeyBinder.getKeyName(key);

      msgKeyConflict.delete(0, msgKeyConflict.length());
      msgKeyConflict.append("Key ").append(keyName);
      msgKeyConflict.append(" is already in use for '");
      msgKeyConflict.append(KeyBindings.actionNames[actionOld]).append("'.");
      msgKeyConflict.append("\nDo you want to unset it from '");
      msgKeyConflict.append(KeyBindings.actionNames[actionOld]);
      msgKeyConflict.append("' and use it for '");
      msgKeyConflict.append(KeyBindings.actionNames[actionToBind]).append("' ?");
      alertKeyConflict.setString(msgKeyConflict.toString());

      display.setCurrent(alertKeyConflict);

    } else { // key is valid and free

      keyBindings.bindKeyToAction(actionToBind, key);

      updateList(actionToBind);

      display.setCurrent(this);
    }
  }