When a new key is bound other commands bound to this key are removed

- On binding new key existing keys are searched
- If key is in use the old one is removed
- ControlKey is updated with a placeholder key value

#story[1197]
main
Jessica Syder 8 years ago
parent 2188ddc3a3
commit ce47b0d813

@ -114,7 +114,15 @@ public class KeyBindingsController {
anchor.addEventFilter(KeyEvent.KEY_PRESSED, event -> {
// if a button was clicked
if (currentButton != null) {
System.out.println("button is clicked");
// check if a button is already mapped to this key
for (int i = 1; i < lstKey.getItems().size(); i++) {
Button button = (Button)lstKey.getItems().get(i);
// update buttons text and remove key binding from command
if (button.getText() == event.getCode().toString()) {
button.setText("");
newKeyFactory.updateKey(button.getId(), button.getId());
}
}
// update text on the button
currentButton.setText(event.getCode().toString());
// update the control key

Loading…
Cancel
Save