public abstract class AbstractFocusable extends AbstractComponent implements Component.Focusable, FieldEvents.FocusNotifier, FieldEvents.BlurNotifier
Component.ErrorEvent, Component.Event, Component.Focusable, Component.Listener
ClientConnector.AttachEvent, ClientConnector.AttachListener, ClientConnector.ConnectorErrorEvent, ClientConnector.DetachEvent, ClientConnector.DetachListener
Sizeable.Unit
DESIGN_ATTR_PLAIN_TEXT
SIZE_UNDEFINED, UNITS_CM, UNITS_EM, UNITS_EX, UNITS_INCH, UNITS_MM, UNITS_PERCENTAGE, UNITS_PICAS, UNITS_PIXELS, UNITS_POINTS
Modifier | Constructor and Description |
---|---|
protected |
AbstractFocusable() |
Modifier and Type | Method and Description |
---|---|
Registration |
addBlurListener(FieldEvents.BlurListener listener)
Adds a
BlurListener to the Component which gets fired
when a Field loses keyboard focus. |
Registration |
addFocusListener(FieldEvents.FocusListener listener)
Adds a
FocusListener to the Component which gets fired
when a Field receives keyboard focus. |
void |
focus()
Sets the focus for this component if the component is
Focusable . |
protected TabIndexState |
getState()
Returns the shared state bean with information to be sent from the server
to the client.
|
protected TabIndexState |
getState(boolean markAsDirty)
Returns the shared state for this connector.
|
int |
getTabIndex()
Gets the tabulator index of the
Focusable component. |
void |
setTabIndex(int tabIndex)
Sets the tabulator index of the
Focusable component. |
addContextClickListener, addListener, addShortcutListener, addStyleName, attach, beforeClientResponse, detach, findAncestor, fireComponentErrorEvent, fireComponentEvent, getActionManager, getCaption, getComponentError, getCustomAttributes, getData, getDebugId, getDescription, getErrorMessage, getHeight, getHeightUnits, getIcon, getId, getLocale, getParent, getPrimaryStyleName, getStyleName, getWidth, getWidthUnits, isCaptionAsHtml, isConnectorEnabled, isEnabled, isOrHasAncestor, isReadOnly, isRequiredIndicatorVisible, isResponsive, isVisible, readDesign, removeContextClickListener, removeListener, removeShortcutListener, removeStyleName, setCaption, setCaptionAsHtml, setComponentError, setData, setDebugId, setDescription, setDescription, setEnabled, setHeight, setHeight, setHeightUndefined, setIcon, setId, setLocale, setParent, setPrimaryStyleName, setReadOnly, setRequiredIndicatorVisible, setResponsive, setSizeFull, setSizeUndefined, setStyleName, setVisible, setWidth, setWidth, setWidthUndefined, writeDesign
addAttachListener, addDetachListener, addExtension, addListener, addListener, addListener, addMethodInvocationToQueue, createState, encodeState, equals, fireEvent, getAllChildrenIterable, getConnectorId, getErrorHandler, getExtensions, getListeners, getResource, getRpcManager, getRpcProxy, getSession, getStateType, getUI, handleConnectorRequest, hashCode, hasListeners, isAttached, isThis, markAsDirty, markAsDirtyRecursive, registerRpc, registerRpc, removeAttachListener, removeDetachListener, removeExtension, removeListener, removeListener, removeListener, removeListener, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandler, setResource, updateDiffstate
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
addListener, addStyleName, addStyleNames, attach, getCaption, getDescription, getIcon, getId, getLocale, getParent, getPrimaryStyleName, getStyleName, getUI, isEnabled, isVisible, readDesign, removeListener, removeStyleName, removeStyleNames, setCaption, setEnabled, setIcon, setId, setParent, setPrimaryStyleName, setStyleName, setStyleName, setVisible, writeDesign
addAttachListener, addDetachListener, beforeClientResponse, detach, encodeState, getErrorHandler, getExtensions, getRpcManager, getStateType, handleConnectorRequest, isAttached, isConnectorEnabled, markAsDirty, markAsDirtyRecursive, removeAttachListener, removeDetachListener, removeExtension, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandler
getConnectorId
getHeight, getHeightUnits, getWidth, getWidthUnits, setHeight, setHeight, setHeightUndefined, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidthUndefined
public Registration addBlurListener(FieldEvents.BlurListener listener)
FieldEvents.BlurNotifier
BlurListener
to the Component which gets fired
when a Field
loses keyboard focus.addBlurListener
in interface FieldEvents.BlurNotifier
listener
- the blur listener to add, not nullFieldEvents.BlurListener
,
Registration
public Registration addFocusListener(FieldEvents.FocusListener listener)
FieldEvents.FocusNotifier
FocusListener
to the Component which gets fired
when a Field
receives keyboard focus.addFocusListener
in interface FieldEvents.FocusNotifier
listener
- the focus listener to add, not nullFieldEvents.FocusListener
,
Registration
public void focus()
AbstractComponent
Focusable
.focus
in interface Component.Focusable
focus
in class AbstractComponent
FieldEvents
,
FieldEvents.FocusEvent
,
FieldEvents.FocusListener
,
FieldEvents.BlurEvent
,
FieldEvents.BlurListener
public int getTabIndex()
Component.Focusable
Focusable
component.getTabIndex
in interface Component.Focusable
Focusable
componentComponent.Focusable.setTabIndex(int)
public void setTabIndex(int tabIndex)
Component.Focusable
Focusable
component.
The tab index property is used to specify the order in which the
fields are focused when the user presses the Tab key. Components with
a defined tab index are focused sequentially first, and then the
components with no tab index.
Form loginBox = new Form(); loginBox.setCaption("Login"); layout.addComponent(loginBox); // Create the first field which will be focused TextField username = new TextField("User name"); loginBox.addField("username", username); // Set focus to the user name username.focus(); TextField password = new TextField("Password"); loginBox.addField("password", password); Button login = new Button("Login"); loginBox.getFooter().addComponent(login); // An additional component which natural focus order would // be after the button. CheckBox remember = new CheckBox("Remember me"); loginBox.getFooter().addComponent(remember); username.setTabIndex(1); password.setTabIndex(2); remember.setTabIndex(3); // Different than natural place login.setTabIndex(4);
After all focusable user interface components are done, the browser can begin again from the component with the smallest tab index, or it can take the focus out of the page, for example, to the location bar.
If the tab index is not set (is set to zero), the default tab order is used. The order is somewhat browser-dependent, but generally follows the HTML structure of the page.
A negative value means that the component is completely removed from the tabulation order and can not be reached by pressing the Tab key at all.
setTabIndex
in interface Component.Focusable
tabIndex
- the tab order of this component. Indexes usually start
from 1. Zero means that default tab order should be used.
A negative value means that the field should not be
included in the tabbing sequence.Component.Focusable.getTabIndex()
protected TabIndexState getState()
AbstractComponent
getState
in class AbstractComponent
protected TabIndexState getState(boolean markAsDirty)
AbstractClientConnector
getState
in class AbstractComponent
markAsDirty
- true if the connector should automatically be marked dirty,
false otherwiseAbstractClientConnector.getState()
Copyright © 2018 Vaadin Ltd. All rights reserved.