Module org.tentackle.fx
Class PrefixSelectionFeature<T extends javafx.scene.control.Control>
java.lang.Object
org.tentackle.fx.component.config.PrefixSelectionFeature<T>
- Type Parameters:
T- the control type
Select items according to a prefix.
Useful for ComboBox and ChoiceBox but can be applied to any control providing a list of items that can be selected.
The prefix selection is case-sensitive, if the first typed character is uppercase.
Useful for ComboBox and ChoiceBox but can be applied to any control providing a list of items that can be selected.
The prefix selection is case-sensitive, if the first typed character is uppercase.
- Author:
- harald
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final BooleanSupplierstatic final StringTo enable camel case preselection, invoke:protected final Tstatic final StringTo disable this feature, invoke:protected final Supplier<javafx.util.StringConverter>protected final Supplier<Collection>protected final StringBuilder -
Constructor Summary
ConstructorsConstructorDescriptionPrefixSelectionFeature(T control, BooleanSupplier asYouTypeCondition, Supplier<Collection> itemProvider, Supplier<javafx.util.StringConverter> itemConverter, Consumer<Integer> selector) Creates a prefix selection feature. -
Method Summary
Modifier and TypeMethodDescriptionvoidConfigures the control to support this feature.protected javafx.event.EventHandler<javafx.scene.input.KeyEvent>Creates the handler to catch the key events.protected StringGets the prefix string to be used forisItemMatching(java.lang.String, java.lang.Object).protected booleanReturns whether preselection via camelcase is enabled.protected booleanReturns whether this feature is enabled for the control.protected booleanisItemMatching(String prefix, Object item) Returns whether item is matching prefix string.protected booleanReturns whether selection by key is enabled.protected voidScrolls to the selected index in the dropdown.protected voidselect()Select an item according to the current prefix.
-
Field Details
-
ENABLED
To disable this feature, invoke:
control.getProperties().remove(PrefixSelectionFeature.ENABLED);
- See Also:
-
CAMEL_CASE
To enable camel case preselection, invoke:
control.getProperties().put(PrefixSelectionFeature.ENABLED, PrefixSelectionFeature.CAMEL_CASE);
- See Also:
-
control
-
asYouTypeCondition
-
itemProvider
-
itemConverter
-
selector
-
prefixBuf
-
-
Constructor Details
-
PrefixSelectionFeature
public PrefixSelectionFeature(T control, BooleanSupplier asYouTypeCondition, Supplier<Collection> itemProvider, Supplier<javafx.util.StringConverter> itemConverter, Consumer<Integer> selector) Creates a prefix selection feature.- Parameters:
control- the control to add this feature toasYouTypeCondition- the condition to activate preselection by keystrokesitemProvider- the items that can be selecteditemConverter- the item to string converterselector- the selector to select an item by its index
-
-
Method Details
-
configure
public void configure()Configures the control to support this feature. -
scrollToIndexInDropDown
protected void scrollToIndexInDropDown()Scrolls to the selected index in the dropdown. -
createHandler
protected javafx.event.EventHandler<javafx.scene.input.KeyEvent> createHandler()Creates the handler to catch the key events.- Returns:
- the handler
-
isEnabled
protected boolean isEnabled()Returns whether this feature is enabled for the control.- Returns:
- true if enabled
-
isCamelCaseEnabled
protected boolean isCamelCaseEnabled()Returns whether preselection via camelcase is enabled.- Returns:
- true if camelcase
-
isSelectionByKeyEnabled
protected boolean isSelectionByKeyEnabled()Returns whether selection by key is enabled.- Returns:
- true if enabled
-
select
protected void select()Select an item according to the current prefix. -
getPrefix
Gets the prefix string to be used forisItemMatching(java.lang.String, java.lang.Object).- Returns:
- the prefix string
-
isItemMatching
Returns whether item is matching prefix string.- Parameters:
prefix- the prefix stringitem- the item- Returns:
- true if matching
-