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
Nested ClassesModifier and TypeClassDescriptionstatic final classA builder forSimpleKeyedFocusModel. -
Constructor Summary
Constructors -
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, ornullif not available.booleanChecks if a focus is focused in the target widget.voidsetFocused(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, ornullif not available.- Returns:
- the focused key, or
nullif not available
-
isFocused
Description copied from interface:FocusModelChecks 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:
isFocusedin interfaceFocusModel<K>- Parameters:
focus- the focus to check- Returns:
trueif the focus is focused,falseotherwise
-
setFocused
Description copied from interface:FocusModelApplies 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:
setFocusedin interfaceFocusModel<K>- Parameters:
focus- the focus
-
foci
Description copied from interface:FocusModelReturns a stream of all foci in the target widget.- Specified by:
fociin 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
-