Module org.controlsfx.controls
Package org.controlsfx.control.textfield
Class AutoCompletionBinding<T>
java.lang.Object
org.controlsfx.control.textfield.AutoCompletionBinding<T>
- Type Parameters:
T
- Model-Type of the suggestions
- All Implemented Interfaces:
javafx.event.EventTarget
The AutoCompletionBinding is the abstract base class of all auto-completion bindings.
This class is the core logic for the auto-completion feature but highly customizable.
To use the autocompletion functionality, refer to the TextFields
class.
The popup size can be modified through its setVisibleRowCount(int)
for the height and all the usual methods for the width.
- See Also:
-
Property Summary
PropertiesTypePropertyDescriptionfinal javafx.beans.property.DoubleProperty
Return the property associated with the max width.final javafx.beans.property.DoubleProperty
Return the property associated with the min width.final javafx.beans.property.ObjectProperty
<javafx.event.EventHandler<AutoCompletionBinding.AutoCompletionEvent<T>>> final javafx.beans.property.DoubleProperty
Return the property associated with the pref width.final javafx.beans.property.IntegerProperty
Return an property representing the maximum number of rows to be visible in the popup when it is showing. -
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
Represents an Event which is fired after an auto completion.static interface
Represents a suggestion fetch request -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
AutoCompletionBinding
(javafx.scene.Node completionTarget, javafx.util.Callback<AutoCompletionBinding.ISuggestionRequest, Collection<T>> suggestionProvider, javafx.util.StringConverter<T> converter) Creates a new AutoCompletionBinding -
Method Summary
Modifier and TypeMethodDescription<E extends javafx.event.Event>
voidaddEventHandler
(javafx.event.EventType<E> eventType, javafx.event.EventHandler<? super E> eventHandler) Registers an event handler to this EventTarget.javafx.event.EventDispatchChain
buildEventDispatchChain
(javafx.event.EventDispatchChain tail) protected abstract void
completeUserInput
(T completion) Complete the current user-input with the provided completion.abstract void
dispose()
Disposes the binding.protected void
fireAutoCompletion
(T completion) Get theAutoCompletePopup
used by this binding.javafx.scene.Node
Gets the target node for auto completionfinal double
Return the max width of the popup.final double
Return the min width of the popup.final javafx.event.EventHandler
<AutoCompletionBinding.AutoCompletionEvent<T>> Gets the value of theonAutoCompleted
property.final double
Return the pref width of the popup.final int
Return the maximum number of rows to be visible in the popup when it is showing.protected void
Hide the auto completion targetsfinal javafx.beans.property.DoubleProperty
Return the property associated with the max width.final javafx.beans.property.DoubleProperty
Return the property associated with the min width.final javafx.beans.property.ObjectProperty
<javafx.event.EventHandler<AutoCompletionBinding.AutoCompletionEvent<T>>> final javafx.beans.property.DoubleProperty
Return the property associated with the pref width.<E extends javafx.event.Event>
voidremoveEventHandler
(javafx.event.EventType<E> eventType, javafx.event.EventHandler<? super E> eventHandler) Unregisters a previously registered event handler from this EventTarget.final void
setDelay
(long delay) Sets the delay in ms between a key press and the suggestion popup being displayed.void
setHideOnEscape
(boolean value) Specifies whether the PopupWindow should be hidden when an unhandled escape key is pressed while the popup has focus.final void
setMaxWidth
(double value) Sets the maxWidth of the popup.final void
setMinWidth
(double value) Sets the minWidth of the popup.final void
setOnAutoCompleted
(javafx.event.EventHandler<AutoCompletionBinding.AutoCompletionEvent<T>> value) Set a event handler which is invoked after an auto completion.final void
setPrefWidth
(double value) Sets the prefWidth of the popup.final void
setUserInput
(String userText) Set the current text the user has enteredfinal void
setVisibleRowCount
(int value) Set the maximum number of rows to be visible in the popup when it is showing.protected void
Show the auto completion popupfinal javafx.beans.property.IntegerProperty
Return an property representing the maximum number of rows to be visible in the popup when it is showing.
-
Property Details
-
visibleRowCount
public final javafx.beans.property.IntegerProperty visibleRowCountPropertyReturn an property representing the maximum number of rows to be visible in the popup when it is showing.- See Also:
-
prefWidth
public final javafx.beans.property.DoubleProperty prefWidthPropertyReturn the property associated with the pref width.- See Also:
-
minWidth
public final javafx.beans.property.DoubleProperty minWidthPropertyReturn the property associated with the min width.- See Also:
-
maxWidth
public final javafx.beans.property.DoubleProperty maxWidthPropertyReturn the property associated with the max width.- See Also:
-
onAutoCompleted
public final javafx.beans.property.ObjectProperty<javafx.event.EventHandler<AutoCompletionBinding.AutoCompletionEvent<T>>> onAutoCompletedProperty- See Also:
-
-
Constructor Details
-
AutoCompletionBinding
protected AutoCompletionBinding(javafx.scene.Node completionTarget, javafx.util.Callback<AutoCompletionBinding.ISuggestionRequest, Collection<T>> suggestionProvider, javafx.util.StringConverter<T> converter) Creates a new AutoCompletionBinding- Parameters:
completionTarget
- The target node to which auto-completion shall be addedsuggestionProvider
- The strategy to retrieve suggestionsconverter
- The converter to be used to convert suggestions to strings
-
-
Method Details
-
setHideOnEscape
public void setHideOnEscape(boolean value) Specifies whether the PopupWindow should be hidden when an unhandled escape key is pressed while the popup has focus.- Parameters:
value
-
-
setUserInput
Set the current text the user has entered- Parameters:
userText
-
-
setDelay
public final void setDelay(long delay) Sets the delay in ms between a key press and the suggestion popup being displayed.- Parameters:
delay
-
-
getCompletionTarget
public javafx.scene.Node getCompletionTarget()Gets the target node for auto completion- Returns:
- the target node for auto completion
-
dispose
public abstract void dispose()Disposes the binding. -
setVisibleRowCount
public final void setVisibleRowCount(int value) Set the maximum number of rows to be visible in the popup when it is showing.- Parameters:
value
-
-
getVisibleRowCount
public final int getVisibleRowCount()Return the maximum number of rows to be visible in the popup when it is showing.- Returns:
- the maximum number of rows to be visible in the popup when it is showing.
-
visibleRowCountProperty
public final javafx.beans.property.IntegerProperty visibleRowCountProperty()Return an property representing the maximum number of rows to be visible in the popup when it is showing.- Returns:
- an property representing the maximum number of rows to be visible in the popup when it is showing.
- See Also:
-
setPrefWidth
public final void setPrefWidth(double value) Sets the prefWidth of the popup.- Parameters:
value
-
-
getPrefWidth
public final double getPrefWidth()Return the pref width of the popup.- Returns:
- the pref width of the popup.
-
prefWidthProperty
public final javafx.beans.property.DoubleProperty prefWidthProperty()Return the property associated with the pref width.- Returns:
- See Also:
-
setMinWidth
public final void setMinWidth(double value) Sets the minWidth of the popup.- Parameters:
value
-
-
getMinWidth
public final double getMinWidth()Return the min width of the popup.- Returns:
- the min width of the popup.
-
minWidthProperty
public final javafx.beans.property.DoubleProperty minWidthProperty()Return the property associated with the min width.- Returns:
- See Also:
-
setMaxWidth
public final void setMaxWidth(double value) Sets the maxWidth of the popup.- Parameters:
value
-
-
getMaxWidth
public final double getMaxWidth()Return the max width of the popup.- Returns:
- the max width of the popup.
-
maxWidthProperty
public final javafx.beans.property.DoubleProperty maxWidthProperty()Return the property associated with the max width.- Returns:
- See Also:
-
getAutoCompletionPopup
Get theAutoCompletePopup
used by this binding. Note that this gives access to the internal API and should be used with great care (and in the expectation that things may break in the future). All relevant methods of the popup are already exposed in this class. The only reason this is exposed is to allow custom skins for the popup.- Returns:
- the
AutoCompletePopup
used by this binding
-
completeUserInput
Complete the current user-input with the provided completion. Sub-classes have to provide a concrete implementation.- Parameters:
completion
-
-
showPopup
protected void showPopup()Show the auto completion popup -
hidePopup
protected void hidePopup()Hide the auto completion targets -
fireAutoCompletion
-
setOnAutoCompleted
public final void setOnAutoCompleted(javafx.event.EventHandler<AutoCompletionBinding.AutoCompletionEvent<T>> value) Set a event handler which is invoked after an auto completion.- Parameters:
value
-
-
getOnAutoCompleted
public final javafx.event.EventHandler<AutoCompletionBinding.AutoCompletionEvent<T>> getOnAutoCompleted()Gets the value of theonAutoCompleted
property.- Property description:
- Returns:
- the value of the
onAutoCompleted
property - See Also:
-
onAutoCompletedProperty
public final javafx.beans.property.ObjectProperty<javafx.event.EventHandler<AutoCompletionBinding.AutoCompletionEvent<T>>> onAutoCompletedProperty()- Returns:
- the
onAutoCompleted
property - See Also:
-
addEventHandler
public <E extends javafx.event.Event> void addEventHandler(javafx.event.EventType<E> eventType, javafx.event.EventHandler<? super E> eventHandler) Registers an event handler to this EventTarget. The handler is called when the menu item receives anEvent
of the specified type during the bubbling phase of event delivery.- Type Parameters:
E
- the specific event class of the handler- Parameters:
eventType
- the type of the events to receive by the handlereventHandler
- the handler to register- Throws:
NullPointerException
- if the event type or handler is null
-
removeEventHandler
public <E extends javafx.event.Event> void removeEventHandler(javafx.event.EventType<E> eventType, javafx.event.EventHandler<? super E> eventHandler) Unregisters a previously registered event handler from this EventTarget. One handler might have been registered for different event types, so the caller needs to specify the particular event type from which to unregister the handler.- Type Parameters:
E
- the specific event class of the handler- Parameters:
eventType
- the event type from which to unregistereventHandler
- the handler to unregister- Throws:
NullPointerException
- if the event type or handler is null
-
buildEventDispatchChain
public javafx.event.EventDispatchChain buildEventDispatchChain(javafx.event.EventDispatchChain tail) - Specified by:
buildEventDispatchChain
in interfacejavafx.event.EventTarget
-