Pressing ESC cancels the selected command's key from being replaced

- focus is shifted away on esc
- focus is shifted away after successful change

#story[1197]
main
Jessica Syder 8 years ago
parent ce47b0d813
commit 278fb65852

@ -4,6 +4,7 @@ import javafx.application.Platform;
import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.control.ListView;
import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyEvent;
import javafx.scene.layout.AnchorPane;
import visualiser.gameController.Keys.ControlKey;
@ -112,8 +113,13 @@ public class KeyBindingsController {
*/
public void setKeyListener(){
anchor.addEventFilter(KeyEvent.KEY_PRESSED, event -> {
// if esc, cancel current button click
if (event.getCode() == KeyCode.ESCAPE){
btnCancel.requestFocus();
currentButton = null;
}
// if a button was clicked
if (currentButton != null) {
else if (currentButton != null) {
// 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);
@ -130,6 +136,7 @@ public class KeyBindingsController {
currentButton.getId());
// remove current button selection
currentButton = null;
btnCancel.requestFocus();
}
event.consume();
});

Loading…
Cancel
Save