Add ESC key handling to AnnotationBuilder

Issue #47 resolved
Bruce Schubert created an issue

Allow the annotation builder to be canceled with the Escape key (if it hasn't been activated yet with a mouse click).

Suggestions for Actions:

        // Force keyboard focus to globe
        wwm.getWorldWindow().requestFocusInWindow();

Suggestion for AnnotationBuilder

    private final KeyAdapter ka = new KeyAdapter() {
        @Override
        public void keyReleased(KeyEvent keyEvent) {
            if (armed && !active && keyEvent.getKeyCode() == KeyEvent.VK_ESCAPE) {
                setArmed(false);
            }
        }
    };

    public void setArmed(boolean armed) {
        ...
        if (armed) {
            this.wwd.getInputHandler().addKeyListener(ka);
            ...
        } else {
            this.wwd.getInputHandler().removeKeyListener(ka);
            ...
        }
    }

Comments (2)

  1. Log in to comment