V - The element typepublic class KeyboardNavigation<V extends org.jboss.elemento.IsElement<?>> extends Object implements elemental2.dom.EventListener
IsElement,
EventListener| Modifier and Type | Class and Description |
|---|---|
static interface |
KeyboardNavigation.EscapeHandler
Escape handler to be called when escape key is pressed
|
static class |
KeyboardNavigation.EventOptions
A utilty class to define stopPropagation and preventDefault options for an event
|
static interface |
KeyboardNavigation.FocusCondition<V>
A condition which evaluates if an item should be focused or not
|
static interface |
KeyboardNavigation.FocusHandler<V>
Focus handler to be called when an item gets focused
|
static interface |
KeyboardNavigation.ItemNavigationHandler<V>
Selection handler to be called when an item gets selected
|
| Constructor and Description |
|---|
KeyboardNavigation(List<V> items) |
| Modifier and Type | Method and Description |
|---|---|
static <V extends org.jboss.elemento.IsElement<?>> |
create(List<V> items)
Creates new navigation for a menu contains a list of items
|
void |
focusAt(int index)
Focuses an item at a specific
index |
KeyboardNavigation<V> |
focusCondition(KeyboardNavigation.FocusCondition<V> focusCondition)
Adds a condition which evaluates if an item should be focused or not
|
void |
focusNext(V item)
Force focus next focusable item based on the provided item
|
void |
focusPrevious(V item)
Focus the focusable item that is before the provided item.
|
void |
focusTopFocusableItem()
apply focus on the top most focusable item
|
void |
handleEvent(elemental2.dom.Event evt) |
boolean |
isLastFocusableItem(V item) |
KeyboardNavigation<V> |
onEscape(KeyboardNavigation.EscapeHandler escapeHandler)
Sets a handler which will be called when escape key is pressed
|
KeyboardNavigation<V> |
onFocus(KeyboardNavigation.FocusHandler<V> focusHandler)
Sets a handler which will be called when an item gets focused
|
KeyboardNavigation<V> |
onSelect(KeyboardNavigation.ItemNavigationHandler<V> selectHandler)
Sets a handler which will be called when an item gets selected
|
KeyboardNavigation<V> |
registerNavigationHandler(String keyCode,
KeyboardNavigation.ItemNavigationHandler<V> navigationHandler) |
KeyboardNavigation<V> |
removeNavigationHandler(String keyCode,
KeyboardNavigation.ItemNavigationHandler<V> navigationHandler) |
KeyboardNavigation<V> |
setEnterHandler(KeyboardNavigation.ItemNavigationHandler<V> enterHandler)
A handler to be called when the user press enter key
|
KeyboardNavigation<V> |
setEnterOptions(KeyboardNavigation.EventOptions enterOptions)
Set global stopPropagation and preventDefault for enter key events
|
KeyboardNavigation<V> |
setGlobalOptions(KeyboardNavigation.EventOptions globalOptions)
Set global stopPropagation and preventDefault for all navigation keyboard events
|
KeyboardNavigation<V> |
setSpaceHandler(KeyboardNavigation.ItemNavigationHandler<V> spaceHandler)
A handler to be called when the user press sapce key
|
KeyboardNavigation<V> |
setSpaceOptions(KeyboardNavigation.EventOptions spaceOptions)
Set global stopPropagation and preventDefault for space key events
|
KeyboardNavigation<V> |
setTabHandler(KeyboardNavigation.ItemNavigationHandler<V> tabHandler)
A handler to be called when the user press tab key
|
KeyboardNavigation<V> |
setTabOptions(KeyboardNavigation.EventOptions tabOptions)
Set global stopPropagation and preventDefault for tab key events
|
public static <V extends org.jboss.elemento.IsElement<?>> KeyboardNavigation<V> create(List<V> items)
V - the element typeitems - the items of the menupublic KeyboardNavigation<V> onFocus(KeyboardNavigation.FocusHandler<V> focusHandler)
focusHandler - A KeyboardNavigation.FocusHandlerpublic KeyboardNavigation<V> onSelect(KeyboardNavigation.ItemNavigationHandler<V> selectHandler)
selectHandler - A KeyboardNavigation.ItemNavigationHandlerpublic KeyboardNavigation<V> onEscape(KeyboardNavigation.EscapeHandler escapeHandler)
escapeHandler - A KeyboardNavigation.EscapeHandlerpublic KeyboardNavigation<V> focusCondition(KeyboardNavigation.FocusCondition<V> focusCondition)
focusCondition - a condition returns true if an item should be focused, false otherwisepublic void handleEvent(elemental2.dom.Event evt)
handleEvent in interface elemental2.dom.EventListenerpublic KeyboardNavigation<V> setEnterHandler(KeyboardNavigation.ItemNavigationHandler<V> enterHandler)
enterHandler - KeyboardNavigation.ItemNavigationHandlerpublic KeyboardNavigation<V> setTabHandler(KeyboardNavigation.ItemNavigationHandler<V> tabHandler)
tabHandler - KeyboardNavigation.ItemNavigationHandlerpublic KeyboardNavigation<V> setSpaceHandler(KeyboardNavigation.ItemNavigationHandler<V> spaceHandler)
spaceHandler - KeyboardNavigation.ItemNavigationHandlerpublic KeyboardNavigation<V> setGlobalOptions(KeyboardNavigation.EventOptions globalOptions)
globalOptions - KeyboardNavigation.EventOptionspublic KeyboardNavigation<V> setEnterOptions(KeyboardNavigation.EventOptions enterOptions)
enterOptions - KeyboardNavigation.EventOptionspublic KeyboardNavigation<V> setTabOptions(KeyboardNavigation.EventOptions tabOptions)
tabOptions - KeyboardNavigation.EventOptionspublic KeyboardNavigation<V> setSpaceOptions(KeyboardNavigation.EventOptions spaceOptions)
spaceOptions - KeyboardNavigation.EventOptionspublic void focusNext(V item)
item - Base item to focus the next item based onpublic boolean isLastFocusableItem(V item)
item - The item to check if is the last focusable item in the items listpublic void focusTopFocusableItem()
public void focusPrevious(V item)
item - The item to base focus onpublic void focusAt(int index)
indexindex - the index of the itempublic KeyboardNavigation<V> registerNavigationHandler(String keyCode, KeyboardNavigation.ItemNavigationHandler<V> navigationHandler)
keyCode - String keyboard key codenavigationHandler - the navigation handler to be registeredpublic KeyboardNavigation<V> removeNavigationHandler(String keyCode, KeyboardNavigation.ItemNavigationHandler<V> navigationHandler)
keyCode - String keyboard key codenavigationHandler - the navigation handler to be removedCopyright © 2019–2022 Dominokit. All rights reserved.