Class SearchField
TextField preset for search: a leading magnifier icon inside the
field and a trailing coupled clear button (the ComboBox-caret idiom). Enter
fires onSubmit(java.util.function.Consumer<java.lang.String>); the clear button empties the field.-
Constructor Summary
ConstructorsConstructorDescriptionA field with a search icon, a clear button and a localized placeholder. -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Empties the field: a caller's write, announced as oneTEXTedit atCODEand reaching no handler.protected voidThe same nodeTextFieldpublishes, said to be a search field and offering the one verb this class adds to it.protected booleanonAccessibilityAction(Accessible.Action action, Accessible.Argument arg) Runs the search, through the same body Enter reaches.protected voidonKeyEvent(KeyEvent event) Key events (focused widget first, then ancestors).The application's response to the user pressing Enter, or an assistive technology's press: called with the current query.Methods inherited from class limn.components.TextField
acceptsTextInput, allowClipboardCopy, allowsWordJumps, baselineOffset, caretPosition, caretRect, composingText, handleUserChange, insertText, invalidateDisplayLine, isMaskComplete, mask, onCanEdit, onChange, onCharTyped, onEdit, onFocusGained, onFocusLost, onMeasure, onMouseEvent, onPaint, onPreedit, onSyntheticAction, paintDisplayText, placeholder, select, selectAll, selectedText, selectionEnd, selectionStart, setCaretPosition, setError, setLeadingIcon, setLeadingIcon, setMask, setPlaceholder, setPlaceholder, setPreferredWidth, setText, setTrailingButton, setTrailingButton, setTrailingButton, setTrailingButton, setValidation, shapeDisplay, showContextMenu, showContextMenuForFocus, text, trailingButtonName, unmaskedText, validationMethods inherited from class limn.scene.Widget
accessibleLabelAccessKey, accessibleLabelTarget, accessibleLabelText, add, add, announceChange, backdropReach, baselineOffsetOf, children, clipboard, clipHeight, clipsChildren, clipWidth, clipX, clipY, controlSize, cursor, declaredControlSize, declaredLayoutDirection, declaredLocale, focusArrivedBackward, focusArrivedByTraversal, height, hitTest, hitTestChild, id, imageCursor, inheritanceHost, invalidate, invalidate, invalidateAccessible, isEnabled, isFocusable, isFocused, isRightToLeft, isSelfEnabled, isShowing, isVisible, isVisibleByItsOwnFlag, layoutBox, layoutDirection, locale, localToScene, localToSceneBounds, markNeedsContainedLayout, markNeedsLayout, markNeedsLayoutInPlace, maxHeight, maxWidth, measure, minHeight, minWidth, moveChild, moveChild, moveChild, neutralBase, notifyChange, notifyTextEdit, observeChanges, onAccessibilityChild, onAccessibilityChildAction, onAccessibilityChildIdentity, onAttached, onDetached, onDragExit, onDragOver, onDragStart, onDrop, onHitTest, onLayout, onPaintOverlay, overlayPassesPointer, paintChildren, paintOutset, paintsDecoration, paintsFromBackdrop, paintWidget, parent, remove, remove, requestFocus, requestFocus, revealInView, revealInView, runHandler, scene, sceneNanos, sceneToLocal, self, setAccessibleDescribedBy, setAccessibleDescription, setAccessibleDescription, setAccessibleIgnored, setAccessibleLabelledBy, setAccessibleName, setAccessibleName, setAccessibleRole, setControlSize, setCursor, setEnabled, setFocusable, setId, setImageCursor, setInheritanceHost, setLayoutDirection, setLocale, setMaxHeight, setMaxWidth, setMinHeight, setMinWidth, setPresentedElsewhere, setTooltip, setTooltip, setVisible, shapeText, textRuler, tooltip, tooltipSource, width, x, y
-
Constructor Details
-
SearchField
public SearchField()A field with a search icon, a clear button and a localized placeholder.
-
-
Method Details
-
onSubmit
The application's response to the user pressing Enter, or an assistive technology's press: called with the current query.TextField.onSubmit, under this class's type; unlike a plain field, a search field takes Enter whether or not a handler is registered.- Overrides:
onSubmitin classTextField- Parameters:
listener- the handler, ornullto clear the slot- Returns:
- this field
- Throws:
IllegalStateException- if a handler is already registered
-
clear
public void clear()Empties the field: a caller's write, announced as oneTEXTedit atCODEand reaching no handler. The trailing button empties it as the user's, through the same seam, soonChangehears the button and not this. UI thread only. -
onKeyEvent
Description copied from class:WidgetKey events (focused widget first, then ancestors).- Overrides:
onKeyEventin classTextField
-
onAccessibility
The same nodeTextFieldpublishes, said to be a search field and offering the one verb this class adds to it.The role is written after the super call and cannot move before it. A role is a plain write to the node's slot, so the last one wins, and the field's own hook writes
TEXT_FIELDinto it; a subclass that declared its role first would publish a search field as a plain one. That it lands on this widget's node rather than on the trailing button's is the other half of the same ordering, and rests on the super hook closing every synthetic child it opened.Everything else a reader hears here is inherited and is deliberately not restated: the contents with the caret and the selection,
EDITABLE, the context menu, and the trailing button as a child node. What this class contributes to that button is its name, given in the constructor, and not a node of its own — the button is the field's generic trailing region and declaring a second one would publish it twice.The name needs no line at all: it is the placeholder the constructor installs, which makes this the one widget in the toolkit that arrives already named with no application involvement. It is the placeholder whether or not there is anything typed in the field — conditioning it on emptiness would rename the node on the first keystroke and rename it back on the last backspace — and because the node always has a name, a tooltip on a search field becomes its description instead.
Nothing is derived here and nothing may be: both statements are constants, so a field whose caret is blinking spends no memory concluding that nothing about it has moved.
- Overrides:
onAccessibilityin classTextField- Parameters:
a- the node being described; write into it, and never keep it
-
onAccessibilityAction
Runs the search, through the same body Enter reaches.Everything else goes to
super, and that clause is the one this class cannot do without. A search field is still a text field: the whole-value set an assistive technology is promised on every text control, the caret and selection verbs and the context menu are all the base class's, and a subclass that swallowed them to answer one verb of its own would be the single text widget in the toolkit a reader cannot write into.The enabled check is here and not in
submit(). The key path is gated by the scene's own dispatch and never travels this way, and the dispatcher has already walked this widget and its ancestors; this is the same restatement the other action hooks in the toolkit carry, and it belongs to the door rather than to the room.- Overrides:
onAccessibilityActionin classTextField- Parameters:
action- what is being askedarg- the argument, which this verb does not take- Returns:
- whether this widget did it
-