Interface SelectionApi

All Superinterfaces:
com.vaadin.flow.component.HasElement, com.vaadin.flow.component.shared.HasTextSelection, Serializable
All Known Subinterfaces:
FluentVaadinTextField<S,F,T>
All Known Implementing Classes:
VBigDecimalField, VDatePicker, VEmailField, VIntegerField, VNumberField, VPasswordField, VTextArea, VTextField

public interface SelectionApi extends com.vaadin.flow.component.shared.HasTextSelection
Text selection helpers for field components wrapping a native input.

Since Vaadin 25.4 the setters (HasTextSelection.setSelectionRange(int, int), HasTextSelection.selectAll() and HasTextSelection.setCursorPosition(int)) come from the core HasTextSelection interface. This interface adds asynchronous getters for the current selection and cursor position, and makes the selection setters available also for fields that don't support them in core (like EmailField, NumberField, IntegerField and DatePicker).

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static interface 
     

    Nested classes/interfaces inherited from interface com.vaadin.flow.component.shared.HasTextSelection

    com.vaadin.flow.component.shared.HasTextSelection.TextSelectionJs
  • Method Summary

    Modifier and Type
    Method
    Description
    default void
    getCursorPosition(com.vaadin.flow.function.SerializableConsumer<Integer> callback)
    Asynchronously gets the current cursor position for this field.
    default void
    Asynchronously gets the current selection for this field.

    Methods inherited from interface com.vaadin.flow.component.HasElement

    getElement

    Methods inherited from interface com.vaadin.flow.component.shared.HasTextSelection

    selectAll, setCursorPosition, setSelectionRange
  • Method Details

    • getSelectionRange

      default void getSelectionRange(SelectionApi.SelectionRangeCallback callback)
      Asynchronously gets the current selection for this field.
      Parameters:
      callback - the callback to notify the selection
    • getCursorPosition

      default void getCursorPosition(com.vaadin.flow.function.SerializableConsumer<Integer> callback)
      Asynchronously gets the current cursor position for this field.
      Parameters:
      callback - the callback to notify the position