1. ControlsFX
  2. ControlsFX
  3. ControlsFX
  4. Issues

Issues

Issue #781 new

Add ability to setConsumeAutoHidingEvents on AutoCompletionBinding popup

Paul Furbacher
created an issue

A somewhat standard gesture for auto-complete text fields is to hit the escape key to clear the characters that have been entered by the user. The escape key is also used to hide the suggestion popup. But because the AutoCompletionBinding popup (private field) does not set the PopupWindow to consume auto hiding events (i.e., pressing the escape key), not only is the popup hidden, but the text field is cleared. Ideally, hiding the popup should consume the ESC key pressed event, and the user would have to press ESC a second time to clear the text field.

Comments about the PopupWindow.consumeAutoHidingEvents property speak directly to this kind of situation:

   /**
     * Specifies whether the event, which caused the Popup to hide, should be
     * consumed. Having the event consumed prevents it from triggering some
     * additional UI response in the Popup's owner window.
     * @defaultValue true
     * @since JavaFX 2.2
     */

I'm pretty sure that the only thing needed would be to add the following methods to AutoCompletionBinding:

    public final void setConsumeAutoHidingEvents(boolean value) {
        autoCompletionPopup.set(value);
    }

    public final boolean getConsumeAutoHidingEvents() {
        return autoCompletionPopup.get();
    }

I don't have time to further explore this solution now, but may have some in a few weeks.

Comments (2)

  1. Paul Furbacher reporter

    I had a bit of time to look at this. Without a change to javafx.stage.PopupWindow.PopupEventRedirector.handleKeyEvent() which returns from the if (scene != null)... block without checking the value of consumeAutoHidingEvents, adding the two methods noted in my original description would have no effect.

    It will be a very long time before I could get set up to delve into the JavaFX code.

  2. Log in to comment