Class EnterClaims
java.lang.Object
com.vaadin.swingbridge.surrogates.EnterClaims
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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceA component with an Enter binding of its own; asked only while it, or a descendant, has focus. -
Method Summary
Modifier and TypeMethodDescriptionstatic booleancommittedThisRoundTrip(com.vaadin.flow.component.Component component) WhethernoteClientCommit(Component)markedcomponentin the current round trip.static voidnoteClientCommit(com.vaadin.flow.component.Component component) Records that the browser committedcomponent's value in the round trip being processed.
-
Method Details
-
noteClientCommit
public static void noteClientCommit(com.vaadin.flow.component.Component component) Records that the browser committedcomponent'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
DatePickerandIntegerField). -
committedThisRoundTrip
public static boolean committedThisRoundTrip(com.vaadin.flow.component.Component component) WhethernoteClientCommit(Component)markedcomponentin the current round trip.
-