Skip to content

Commit

Permalink
Fixed Esc behavior and connected Delete and Esc to Clear Entry and Clear
Browse files Browse the repository at this point in the history
  • Loading branch information
M4444 committed Jun 1, 2018
1 parent e606438 commit 5b97478
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
Binary file modified dist/C41C.jar
Binary file not shown.
15 changes: 11 additions & 4 deletions src/c41c/Window.java
Original file line number Diff line number Diff line change
Expand Up @@ -1339,9 +1339,14 @@ void LABEL_bitGroup_MousePressed(MouseEvent evt) {
private void addKeyDispatcher() {
KeyboardFocusManager.getCurrentKeyboardFocusManager().addKeyEventDispatcher((KeyEvent e) -> {
if (e.getID()==KeyEvent.KEY_PRESSED) {
if (getFocusOwner().getClass().getSimpleName().equals("BorderlessTextField") &&
e.getKeyCode() != KeyEvent.VK_ESCAPE)
// Disable entry when 'bit length' text field is focused
if (getFocusOwner().getClass().getSimpleName().equals("BorderlessTextField")) {
if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
System.out.println("Esc");
requestFocus();
}
return false;
}
// Disable entry when Ctrl or Alt is being held down
if (e.isControlDown() || e.isAltDown())
return false;
Expand All @@ -1350,8 +1355,10 @@ private void addKeyDispatcher() {
default:
return false;
case KeyEvent.VK_ESCAPE:
System.out.println("Esc");
requestFocus();
BUTTON_CC.doClick();
break;
case KeyEvent.VK_DELETE:
BUTTON_CE.doClick();
break;
case KeyEvent.VK_BACK_SPACE:
BUTTON_backspace.doClick();
Expand Down

0 comments on commit 5b97478

Please sign in to comment.