Class SimpleKeyedFocusModel<K>
java.lang.Object
io.github.cottonmc.cotton.gui.widget.focus.SimpleKeyedFocusModel<K>
- Type Parameters:
K
- the focus key type
- All Implemented Interfaces:
FocusModel<K>
A
FocusModel
implementation that wraps a List
of foci.
New instances can be created with the constructor or the builder.- Since:
- 7.0.0
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic final class
A builder forSimpleKeyedFocusModel
. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic <K> SimpleKeyedFocusModel.Builder
<K> builder()
Creates a builder forSimpleKeyedFocusModel
.foci()
Returns a stream of all foci in the target widget.Returns the focused key, ornull
if not available.boolean
Checks if a focus is focused in the target widget.void
setFocused
(Focus<K> focus) Applies a focus to the target widget.
-
Constructor Details
-
SimpleKeyedFocusModel
Constructs a keyed focus model.- Parameters:
foci
- the foci- Throws:
IllegalArgumentException
- if there are duplicate keys
-
-
Method Details
-
getFocusedKey
Returns the focused key, ornull
if not available.- Returns:
- the focused key, or
null
if not available
-
isFocused
Description copied from interface:FocusModel
Checks if a focus is focused in the target widget. If the target widget is not focused itself, none of its foci should have focus.- Specified by:
isFocused
in interfaceFocusModel<K>
- Parameters:
focus
- the focus to check- Returns:
true
if the focus is focused,false
otherwise
-
setFocused
Description copied from interface:FocusModel
Applies a focus to the target widget.This method does not need to request the GUI's focus for the widget; that is the responsibility of the caller.
- Specified by:
setFocused
in interfaceFocusModel<K>
- Parameters:
focus
- the focus
-
foci
Description copied from interface:FocusModel
Returns a stream of all foci in the target widget.- Specified by:
foci
in interfaceFocusModel<K>
- Returns:
- a stream of all foci in the target widget
-
builder
Creates a builder forSimpleKeyedFocusModel
.- Type Parameters:
K
- the focus key type- Returns:
- the builder
-