Class EnterClaims

java.lang.Object
com.vaadin.swingbridge.surrogates.EnterClaims

public final class EnterClaims extends Object
Whether the focused component takes Enter itself, so the root pane's default button must not (SD_enter_claims). Swing offers a key to the focused component's WHEN_FOCUSED bindings before any window-wide one, and a binding whose action is enabled consumes it:
class SJTextArea extends TextArea implements EnterClaims.Claimant {
    public boolean claimsEnter() { return isEditable(); }            // Enter inserts a newline
}
// a formatted field: Enter commits an edit, and only an unedited field lets it through
addValueChangeListener(e -> { if (e.isFromClient()) EnterClaims.noteClientCommit(this); });
public boolean claimsEnter() { return EnterClaims.committedThisRoundTrip(this); }

UI-thread-confined.

  • Method Details

    • noteClientCommit

      public static void noteClientCommit(com.vaadin.flow.component.Component component)
      Records that the browser committed component's value in the round trip being processed. The mark lasts until the response is written.

      This is how "edited" reaches the server at all: the browser sends typed text only on commit, and Vaadin's fields commit in their own Enter handler, so the value change arrives ahead of the default button's shortcut in the same round trip (measured on DatePicker and IntegerField).

    • committedThisRoundTrip

      public static boolean committedThisRoundTrip(com.vaadin.flow.component.Component component)
      Whether noteClientCommit(Component) marked component in the current round trip.