public abstract class AbstractIntelliHints<T> extends java.lang.Object implements IntelliHints<T>
AbstractIntelliHints is an abstract implementation of IntelliHints. It covers functions such as
showing the hint popup at the correct position, delegating keystrokes, updating and selecting hint. The only thing
that is left out to subclasses is the creation of the hint popup.| Type | Property and Description |
|---|---|
javafx.beans.property.BooleanProperty |
autoPopup |
javafx.beans.property.ObjectProperty<javafx.util.Duration> |
showHintsDelay |
PROPERTY_INTELLI_HINTS| Constructor and Description |
|---|
AbstractIntelliHints(javafx.scene.control.TextInputControl textInputControl)
Creates an IntelliHints object for a given TextInputControl such as TextField or TextArea.
|
| Modifier and Type | Method and Description |
|---|---|
void |
acceptHint(T selected)
After user has selected a item in the hints popup, this method will update TextInputControl accordingly to accept
the hint.
|
void |
addShowHintsKeyCombination(javafx.scene.input.KeyCombination combination)
Adds a new key stroke to show hints popup.
|
javafx.beans.property.BooleanProperty |
autoPopupProperty() |
protected javafx.stage.Popup |
createPopup() |
javafx.scene.input.KeyCombination[] |
getAllShowHintsKeyStrokes()
Gets all key strokes that will show hints popup.
|
protected java.lang.Object |
getContext()
Gets the context for hints.
|
protected abstract javafx.scene.input.KeyCombination[] |
getDelegateKeyCombination()
Gets the delegate keystrokes.
|
protected abstract javafx.scene.Node |
getDelegateNode()
Gets the delegate node in the hint popup.
|
static <T> IntelliHints<T> |
getIntelliHints(javafx.scene.Node node)
Gets the IntelliHints object if it was installed on the node before.
|
javafx.util.Duration |
getShowHintsDelay()
Gets the delay after the key is pressed to show hints.
|
protected javafx.scene.input.KeyCombination |
getShowHintsKeyCombination()
Gets the keystroke that will trigger the hint popup.
|
javafx.scene.control.TextInputControl |
getTextInputControl() |
protected void |
hideHintsPopup()
Hides the hints popup.
|
boolean |
isAutoPopup()
Returns whether the hints popup is automatically displayed.
|
boolean |
isHintsPopupVisible()
Checks if the hints popup is visible.
|
protected boolean |
isMultiline()
Returns whether this IntelliHints'
TextInputControl supports single-line text or multi-line text. |
void |
removeShowHintKeyCombination(javafx.scene.input.KeyCombination combination)
Removes a key stroke from the list to show hints popup.
|
void |
setAutoPopup(boolean autoPopup)
Sets whether the popup should be displayed automatically.
|
void |
setHintsEnabled(boolean enabled)
Enables or disables the hints popup.
|
void |
setShowHintsDelay(javafx.util.Duration showHintsDelay)
Sets the delay after the key is pressed to show hints.
|
void |
showHints()
Shows the hints popup which contains the hints.
|
javafx.beans.property.ObjectProperty<javafx.util.Duration> |
showHintsDelayProperty() |
protected void |
showHintsPopup()
This method will call
showHints() if and only if the text control is enabled and has focus. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitcreateHintsNode, getSelectedHint, updateHintspublic javafx.beans.property.BooleanProperty autoPopupProperty
isAutoPopup(),
setAutoPopup(boolean)public javafx.beans.property.ObjectProperty<javafx.util.Duration> showHintsDelayProperty
getShowHintsDelay(),
setShowHintsDelay(Duration)public AbstractIntelliHints(javafx.scene.control.TextInputControl textInputControl)
textInputControl - the text input control.protected javafx.stage.Popup createPopup()
public javafx.scene.control.TextInputControl getTextInputControl()
public void acceptHint(T selected)
For TextArea, the default implementation will insert the hint into current caret position. For TextField, by
default it will replace the whole content with the item user selected. Subclass can always choose to override it
to accept the hint in a different way. For example, FileIntelliHints will
append the selected item at the end of the existing text in order to complete a full file path.
acceptHint in interface IntelliHints<T>selected - the selected hintprotected boolean isMultiline()
TextInputControl supports single-line text or multi-line text.true if the node supports multiple text lines, false otherwise.protected void showHintsPopup()
showHints() if and only if the text control is enabled and has focus.public void showHints()
IntelliHints.updateHints(Object). Only if it returns
true, the popup will be shown. You can call this method to fore the hints to be displayed.protected java.lang.Object getContext()
We provide a default context in AbstractIntelliHints. If it's a TextArea, the context will be the string at the caret line from line beginning to the caret position. If it's a TextField, the context will be whatever string in the text field. Subclass can always override it to return the context that is appropriate.
protected void hideHintsPopup()
public void setHintsEnabled(boolean enabled)
enabled - true to enable the hints popup. Otherwise false.public boolean isHintsPopupVisible()
public javafx.beans.property.BooleanProperty autoPopupProperty()
isAutoPopup(),
setAutoPopup(boolean)public boolean isAutoPopup()
setAutoPopup(boolean)public void setAutoPopup(boolean autoPopup)
autoPopup - true or falseprotected abstract javafx.scene.input.KeyCombination[] getDelegateKeyCombination()
When hint popup is visible, the keyboard focus never leaves the text control. However the hint popup usually
contains a control that user will try to use navigation key to select an item. For example, use UP and DOWN key
to navigate the list. Those keystrokes, if the popup is visible, will be delegated to the the control that
returns from getDelegateNode().
NOTE: Since this method would be invoked inside the constructor of AbstractIntelliHints, please do not try to return a field because the field is not initiated yet at this time.
getDelegateNode() when hint popup is shown.protected abstract javafx.scene.Node getDelegateNode()
protected javafx.scene.input.KeyCombination getShowHintsKeyCombination()
By default, it's the DOWN key for TextField and CTRL+SPACE for TextArea.
public javafx.beans.property.ObjectProperty<javafx.util.Duration> showHintsDelayProperty()
getShowHintsDelay(),
setShowHintsDelay(Duration)public void setShowHintsDelay(javafx.util.Duration showHintsDelay)
By default, the delay time is 200ms Duration.
showHintsDelay - the delay timepublic javafx.util.Duration getShowHintsDelay()
setShowHintsDelay(Duration)public void addShowHintsKeyCombination(javafx.scene.input.KeyCombination combination)
combination - the key strokeremoveShowHintKeyCombination(KeyCombination),
getAllShowHintsKeyStrokes()public void removeShowHintKeyCombination(javafx.scene.input.KeyCombination combination)
combination - the key strokepublic javafx.scene.input.KeyCombination[] getAllShowHintsKeyStrokes()
public static <T> IntelliHints<T> getIntelliHints(javafx.scene.Node node)
T - the data type of the hintsnode - the node that has IntelliHints installed