Class ComboBox<T>
Keyboard: Space/Enter/Down opens; Up/Down move the highlight; Enter commits; Esc closes. The popup takes no focus when it opens; the combo keeps it, so clicking anywhere else in the parent window closes the popup via focus loss. A click in the list that chooses nothing, on its scroll bar or its padding, makes the list's window the desktop's key window; the keys it then receives are handed to the combo, and closing the list gives the parent window the keyboard back. Headless scenes (tests) keep the same open/highlight/commit state machine without a native window.
In-scene fallback. Where the window reports no
WindowPeer.supportsAbsolutePositioning() (Wayland), a list in a window of
its own would open somewhere other than under the field, and over a
fullscreen window it would minimize an
owner fullscreen at a named mode at the first click, while one at the mode the display is in
already covers the screen and leaves a list window no edge to reach past, so in both the list is
drawn as an overlay inside the owner window instead (see DisplayMode). Same rows, same
keys, same type-ahead; the difference is that it is clamped to that window rather than to the
display, so a combo near the bottom edge shows fewer rows and scrolls sooner. Chosen by the
platform, not by the application, and popupWindow() is null throughout. Chosen
when the list opens; a list already open in a window of its own when the owner enters or leaves
fullscreen closes instead, as if dismissed, with the selection as it was: see
DisplayMode.
Field and dropdown share one ControlSize step: the panel is the root
of its own window-bound Scene, so it inherits through
Widget.setInheritanceHost(limn.scene.Widget<?>) rather than through the tree. A dropdown at a different
density from the field that opened it is simply a bug, so there is no setter on the panel.
The in-scene presentation carries the same link on the overlay layer, which is the parentless
widget there — the panel's own would be ignored, because a host link on a widget that has a
parent loses to the tree.
The LayoutDirection arrives by that same link and for that same reason: a list
whose rows read the other way from the field that opened them is a bug rather than a
configuration. Reading right to left the label sits against the right edge, the chevron takes
the gutter on the left, the list hangs from the field's right edge and the marker column, the
row labels and the scrollbar all move to the other side. The chevron itself does not turn
over: it points up and down.
-
Constructor Summary
ConstructorsConstructorDescriptionA combo whose items come from a search the application runs as the user types, and start empty:new ComboBox<>(Customer::name).setSearch(text -> Ui.async(() -> find(text))).A combo over items that read as themselves: aStringas it is, anI18nStringin the UI language (a theme or unit picker, whose words follow a language change), anything else by itstoString().A combo over items that read astextsays:new ComboBox<>(customers, Customer::name). -
Method Summary
Modifier and TypeMethodDescriptionprotected Widget<?> An editable combo's caption names its editor, where the caret and the reader are.protected floatMixed-step rows align on this, not on the box; seeFlex.CrossAlignment.BASELINE.Drops the selection, holding many, or with free text on; a combo that chooses one item always holds one, and refuses.voidclose()Dismisses the popup without changing the selection.protected voidhandleUserChange(Change.Aspect aspect) Runs this widget's application handler for a change it has just announced.intbooleanbooleanbooleanisOpen()Whether the popup is showing.booleanisSelected(int index) static ComboBox<I18nString> localized(List<I18nString> items) A combo whose items follow the UI language: a theme or unit picker, as opposed to a list of file names.protected voidThe field, which is a combo box that is open or shut and is showing one of its items.protected booleanonAccessibilityAction(Accessible.Action action, Accessible.Argument arg) Opens the list, closes it, or picks an item, each through the path the user's own gesture takes.protected booleanonCanEdit(EditCommand command) Whether this widget can do an editing command now: copy with something selected, paste with something to paste, undo with something to take back.protected voidonCharTyped(CharEvent event) Type-ahead: letters typed into an open list jump to what they spell, the way a combo does on Windows and a pop-up button does on GTK and macOS.protected voidA combo removed from the tree must never strand its dropdown on screen: a programmatically-opened popup has no focus to lose, so focus-lost alone does not cover this.protected booleanonEdit(EditCommand command) Does an editing command, as the user's own act.protected voidCalled when this widget takes keyboard focus.protected voidCalled when this widget loses keyboard focus.protected voidonKeyEvent(KeyEvent event) Key events (focused widget first, then ancestors).protected voidonLayout()Containers position children here (measure +Widget.layoutBox(float, float, float, float)per child).protected SizeonMeasure(Constraints constraints) What a label with no strong character of its own falls back to, given the direction the caller already resolved for its pass: an item that is all digits or punctuation ("--","1/2","1.0") reads the way the form around it does.protected voidonMouseEvent(MouseEvent event) Mouse events (bubbling); callevent.consume()when handled.protected voidWidget's own background/content, in local coordinates.The application's response to the user changing the selection: a click on a row, Enter on the highlight, an assistive technology's select, a typed text the field accepted.voidopen()Opens the popup (native window when bound; pure state when headless).@Nullable NativeWindowThe window the open list is drawn in, for an application that captures it or a test that drives it: the list is a window of its own, so a capture of the owner window does not contain it.Selects every item, holding many; nothing holding one.intThe selected item's index.int[]@Nullable TThe selected item itself: one of the items, or what a free text became, ornullwhen an editable combo with free text was emptied.The selected item as it currently reads, in the UI language: empty when nothing is selected.setChipRenderer(@Nullable Function<? super T, ? extends Widget<?>> renderer) Replaces how a chip is drawn in the field of a combo holding many: the widget standing for an item, asked once per item when it is first selected.setDisplayMode(DisplayMode mode) Asks for a presentation of the drop-down list; seeDisplayMode.setEditable(boolean value) Makes the field text the user types into, or a button again: typing filters the list, the arrows walk it, Enter picks the highlighted item and leaving the field picks the item the text names, or puts the selected item's text back.setEmptySelectionAllowed(boolean allowed) Lets a combo holding one item hold none: the list gains a first option that stands for "nothing", whose value isnull, and choosing it empties the combo.setFilter(@Nullable BiPredicate<? super T, String> rule) Replaces the rule an editable combo filters its list by: whether an item matches what is typed.setFreeText(@Nullable Function<String, ? extends T> fromText) Lets an editable combo take a text that names no item, as a "City" that may be new or a tag does: leaving the field with such a text makes it the value, throughfromText, and leaving it empty clears the value.setItemIcon(@Nullable Function<? super T, ? extends @Nullable Icon> icon) Gives each item an icon, shown before its text in the list, in a chip and in the field of a combo holding one item.setItemIcon(@Nullable Function<? super T, ? extends @Nullable Icon> icon, Function<? super T, Icon.Mirroring> mirroring) Gives each item an icon, assetItemIcon(Function)does, and says of each whether its icon means a direction: one that answersIcon.Mirroring.IN_RTL, a back arrow or a paper plane, is drawn flipped while the combo reads right to left.setPlaceholder(String hint) A fixed hint the field shows, muted, while it reads nothing: a combo holding many with none selected, an empty option with no text of its own, an editable combo's emptied text.setPlaceholder(I18nString hint) setPlaceholder(String), in words that follow the UI language.Makes an editable combo take its items from a search the application runs in the background as the user types, instead of filtering a list:text -> Ui.async(() -> find(text)).setSelectedIndex(int index) Selects an item: a caller's write, so it announcesSELECTION/CODEand reaches no handler.setSelectedIndices(int... indices) Selects exactly these items: a caller's write, announced asSELECTION/CODEwhen it moved anything, and reaching no handler.setSelectedItem(T item) Selectsitem: a caller's write, assetSelectedIndex(int)is.setSelectedItems(Collection<? extends T> selection) Selects exactly these items, compared withequals: a caller's write, assetSelectedIndices(int...)is.How many items the combo holds:SelectionMode.SINGLE, the default, orSelectionMode.MULTI, where the list stays open while items are toggled and the field shows them as chips.text()Methods inherited from class limn.scene.Widget
acceptsTextInput, accessibleLabelAccessKey, accessibleLabelText, add, add, announceChange, backdropReach, baselineOffsetOf, caretRect, 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, onDragExit, onDragOver, onDragStart, onDrop, onHitTest, onPaintOverlay, onPreedit, onSyntheticAction, 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
-
ComboBox
A combo over items that read as themselves: aStringas it is, anI18nStringin the UI language (a theme or unit picker, whose words follow a language change), anything else by itstoString(). For items that read some other way, give the text:ComboBox(List, Function).- Parameters:
items- the items, in the order the list shows them; at least one- Throws:
IllegalArgumentException- for an empty list
-
ComboBox
A combo over items that read astextsays:new ComboBox<>(customers, Customer::name). The text may be aStringor anI18nString, which follows the UI language; anything else reads by itstoString(). Asked once per item, here.- Parameters:
items- the items, in the order the list shows them; at least onetext- how an item reads in the field and the list- Throws:
IllegalArgumentException- for an empty list
-
ComboBox
A combo whose items come from a search the application runs as the user types, and start empty:new ComboBox<>(Customer::name).setSearch(text -> Ui.async(() -> find(text))). It is editable from the start, since there is nothing to choose before something is typed.- Parameters:
text- how an item reads in the field and the list
-
-
Method Details
-
localized
A combo whose items follow the UI language: a theme or unit picker, as opposed to a list of file names. The items are held as values, so a language change re-measures the popup instead of leaving yesterday's words in it. -
onSelect
The application's response to the user changing the selection: a click on a row, Enter on the highlight, an assistive technology's select, a typed text the field accepted. Never forsetSelectedIndex(int)or the other setters, which are a caller's writes; to hear every change whatever caused it, watch the combo instead. The handler reads what it needs,selectedItem()or, holding many,selectedItems(), as aListView's does.- Parameters:
handler- the handler, ornullto clear the slot- Returns:
- this combo
- Throws:
IllegalStateException- if a handler is already registered
-
handleUserChange
Description copied from class:WidgetRuns this widget's application handler for a change it has just announced. Called byWidget.runHandler(limn.scene.Change), and so byWidget.notifyChange(limn.scene.Change), only for aUSERorigin and after every watcher has run.A component overrides it once and switches on the aspect, reading its own accessors for the payload: a slider passes
value(), a combo boxselectedIndex(), a text fieldtext(). A component with no handler does not override it.An override that does not recognise the aspect must call
super, because a subclass of a component that has a handler inherits that component's dispatch through this method: aSearchFieldthat overrode this for its own aspect and did not chain would silently deleteTextField's. The ordering lives in the base class, this is the one link in it a subclass can break, and the contract test drives every subclass through its parent's gestures to catch one that does.- Overrides:
handleUserChangein classWidget<ComboBox<T>>- Parameters:
aspect- what changed; the origin isUSERor this is not called
-
selectedIndex
public int selectedIndex()The selected item's index. Never negative for a combo that chooses: it refuses an empty item list and so always has exactly one selection. -1 only for an editable combo with free text (setFreeText(java.util.function.Function<java.lang.String, ? extends T>)), while its value is a text the list does not hold, or none. -
selectedItem
The selected item itself: one of the items, or what a free text became, ornullwhen an editable combo with free text was emptied. Holding many, the first of them in the list's order, ornullfor none. -
selectedText
The selected item as it currently reads, in the UI language: empty when nothing is selected. Holding many, their texts in the list's order, joined as the language joins a list. -
setSelectionMode
How many items the combo holds:SelectionMode.SINGLE, the default, orSelectionMode.MULTI, where the list stays open while items are toggled and the field shows them as chips.NONEis refused: a combo box that chooses nothing is a label. Switching toMULTIstarts with nothing selected, since the item a combo holding one must hold is not one the user chose, and a filter that opened on it would already be filtering; switching back keeps the first selected, or the first item when none was. Each is announced asSELECTION/ADJUSTMENTwhen it moves anything. Not withsetSearch(java.util.function.Function<java.lang.String, ? extends java.util.concurrent.CompletionStage<? extends java.util.List<? extends T>>>)orsetFreeText(java.util.function.Function<java.lang.String, ? extends T>). UI thread only.- Parameters:
mode-SINGLEorMULTI- Returns:
- this combo
- Throws:
IllegalArgumentException- forNONEIllegalStateException- forMULTIon a combo that searches or takes free text
-
selectionMode
- Returns:
- how many items the combo holds; see
setSelectionMode(limn.components.SelectionMode)
-
selectedItems
- Returns:
- the selected items, in the list's order; empty when nothing is selected
-
selectedIndices
public int[] selectedIndices()- Returns:
- every selected item's index, ascending; empty when nothing is selected
-
isSelected
public boolean isSelected(int index) - Parameters:
index- an item- Returns:
- whether it is selected
-
setSelectedIndices
Selects exactly these items: a caller's write, announced asSELECTION/CODEwhen it moved anything, and reaching no handler. Holding one, exactly one index. UI thread only.- Parameters:
indices- items in[0, itemCount)- Returns:
- this combo
- Throws:
IndexOutOfBoundsException- for an index that is not an itemIllegalArgumentException- for other than one index on a combo holding one item
-
setSelectedItems
Selects exactly these items, compared withequals: a caller's write, assetSelectedIndices(int...)is.- Parameters:
selection- some of the items- Returns:
- this combo
- Throws:
IllegalArgumentException- for an item that is not one of them, or for other than one item on a combo holding one
-
selectAll
Selects every item, holding many; nothing holding one. A caller's write, announced asSELECTION/CODEwhen it moved anything. UI thread only.- Returns:
- this combo
-
clearSelection
Drops the selection, holding many, or with free text on; a combo that chooses one item always holds one, and refuses. A caller's write, announced asSELECTION/CODEwhen it moved anything. UI thread only.- Returns:
- this combo
- Throws:
IllegalStateException- on a combo holding one item without free text
-
setEmptySelectionAllowed
Lets a combo holding one item hold none: the list gains a first option that stands for "nothing", whose value isnull, and choosing it empties the combo. It reads as the item text function answers fornull, and shows the icon the icon function answers for it, so the application words it ("None", "Any status") as it words its items; a function that cannot takenullleaves it blank. Turned off while nothing is held, the combo takes the first item. Holding many, a selection may always be empty and the list shows no such option. UI thread only.- Parameters:
allowed- whether the combo may hold nothing- Returns:
- this combo
-
isEmptySelectionAllowed
public boolean isEmptySelectionAllowed()- Returns:
- whether a combo holding one item may hold none; see
setEmptySelectionAllowed(boolean)
-
setFreeText
Lets an editable combo take a text that names no item, as a "City" that may be new or a tag does: leaving the field with such a text makes it the value, throughfromText, and leaving it empty clears the value.null, the default, accepts items only: such a text is refused, put back to the selected item's, and a screen reader is told so. UI thread only.- Parameters:
fromText- how a text becomes an item, ornullto accept items only- Returns:
- this combo
-
setSelectedItem
Selectsitem: a caller's write, assetSelectedIndex(int)is.- Parameters:
item- one of the items, compared withequals- Returns:
- this combo
- Throws:
IllegalArgumentException- ifitemis not one of them
-
setEditable
Makes the field text the user types into, or a button again: typing filters the list, the arrows walk it, Enter picks the highlighted item and leaving the field picks the item the text names, or puts the selected item's text back. The field keeps the caret, the selection, the clipboard and the input method while the list is up, as a text field does. UI thread only.- Parameters:
value- whether the field is editable- Returns:
- this combo
-
isEditable
public boolean isEditable()- Returns:
- whether the field is text the user types into; see
setEditable(boolean)
-
setFilter
Replaces the rule an editable combo filters its list by: whether an item matches what is typed. The default finds the text anywhere in an item's text, ignoring case and accents, and lists the items that start with it first; a predicate lists the items it accepts in their order. UI thread only.- Parameters:
rule- the rule, ornullfor the default- Returns:
- this combo
-
setSearch
public ComboBox<T> setSearch(@Nullable Function<String, ? extends CompletionStage<? extends List<? extends T>>> finder) Makes an editable combo take its items from a search the application runs in the background as the user types, instead of filtering a list:text -> Ui.async(() -> find(text)). The search is asked 200L ms after the last keystroke, the list says it is loading meanwhile, an answer for a text the user has typed past is dropped, and the number found is told to a screen reader. While a search supplies the items the value is held by itself andselectedIndex()answers -1. UI thread only.- Parameters:
finder- the search, ornullto go back to the list in memory- Returns:
- this combo
-
setItemIcon
Gives each item an icon, shown before its text in the list, in a chip and in the field of a combo holding one item. Tinted with the text's ink as aLabel's is, so a picture that must keep its colours is an icon that is not tintable. Asked once per item, here and when a search answers. UI thread only.- Parameters:
icon- an item's icon, answeringnullfor an item without one; ornullto show none- Returns:
- this combo
-
setItemIcon
public ComboBox<T> setItemIcon(@Nullable Function<? super T, ? extends @Nullable Icon> icon, Function<? super T, Icon.Mirroring> mirroring) Gives each item an icon, assetItemIcon(Function)does, and says of each whether its icon means a direction: one that answersIcon.Mirroring.IN_RTL, a back arrow or a paper plane, is drawn flipped while the combo reads right to left. Asked with the icon, and handednullfor the empty option as the icon function is. UI thread only.- Parameters:
icon- an item's icon, answeringnullfor an item without one; ornullto show nonemirroring- whether an item's icon is flipped right to left;Icon.Mirroring.NEVERunless the glyph is directional- Returns:
- this combo
-
setPlaceholder
A fixed hint the field shows, muted, while it reads nothing: a combo holding many with none selected, an empty option with no text of its own, an editable combo's emptied text. It is never the value: an empty option that has words shows them, and the hint only fills a field that would otherwise be blank. It names the combo for a screen reader when nothing else does, as a text field's placeholder does.- Parameters:
hint- the hint; empty for none- Returns:
- this combo
-
setPlaceholder
setPlaceholder(String), in words that follow the UI language. UI thread only.- Parameters:
hint- the hint;I18nString.EMPTYfor none- Returns:
- this combo
-
placeholder
- Returns:
- the hint as it currently reads; see
setPlaceholder(String)
-
setChipRenderer
Replaces how a chip is drawn in the field of a combo holding many: the widget standing for an item, asked once per item when it is first selected. It is drawn and never operated, taking no pointer and no keyboard, and it is not in the accessible tree, since a reader hears the field's value, which names every item. UI thread only.- Parameters:
renderer- the widget for an item, ornullfor the default chip, a pill with the item's icon and text- Returns:
- this combo
- Throws:
IllegalArgumentException- later, when a chip it answers can take the keyboard
-
text
- Returns:
- what the field shows: the text typed into an editable combo, else the selected item's
-
setSelectedIndex
Selects an item: a caller's write, so it announcesSELECTION/CODEand reaches no handler. Selecting what is already selected changes nothing and announces nothing. UI thread only.- Parameters:
index- an item in[0, itemCount)- Throws:
IndexOutOfBoundsException- ifindexis not an item; an index computed from a lookup that missed is a caller's bug here, not a request for the nearest item
-
isOpen
public boolean isOpen()Whether the popup is showing. -
highlightedIndex
public int highlightedIndex()- Returns:
- the highlighted popup row (keyboard navigation state)
-
popupWindow
The window the open list is drawn in, for an application that captures it or a test that drives it: the list is a window of its own, so a capture of the owner window does not contain it. Supported API, not a test hook.- Returns:
- the popup's native window while open, else
null, which is also the answer while an open popup is drawn in the scene, where there is no window to return
-
open
public void open()Opens the popup (native window when bound; pure state when headless). AnnouncesEXPANDED/CODE; the click, the keys and an assistive technology's expand announce it asUSERthrough the same seam. In a scene, nothing happens, and nothing is announced, while the combo box is hidden, drawn as nothing by a transform above it, or on its way out of its window. -
setDisplayMode
Asks for a presentation of the drop-down list; seeDisplayMode. DefaultDisplayMode.NATIVE_WINDOW, so a long list can extend past the window's edge the way a platform combo's does.A preference, not a guarantee. A list asked for
NATIVE_WINDOWis still drawn in scene on a window that cannot be positioned at an anchor (Wayland), and over a fullscreen window, for the reasonsDisplayModegives.IN_SCENEis always honoured, and it is the choice to make when the window has to contain everything it shows: a screenshot, a recording or a screen share of the owner window captures an in-scene list and never a native one.Takes effect on the next open.
-
displayMode
- Returns:
- how the list is presented: while it is open, what it actually chose, including a
fullscreen owner or a platform forcing
IN_SCENEover a request for a window. While it is closed, what was last asked for, since the next open decides afresh over the window as it is then.
-
close
public void close()Dismisses the popup without changing the selection. No-op when closed. AnnouncesEXPANDED/CODE; a dismissal by the user isUSER, and one the widget makes for itself -- the window losing focus, the field being detached -- is an adjustment. -
onMeasure
What a label with no strong character of its own falls back to, given the direction the caller already resolved for its pass: an item that is all digits or punctuation ("--","1/2","1.0") reads the way the form around it does.The resolved direction is a parameter rather than a second read, so that one pass cannot shape a label against one direction and place it against the other. Every strong character still decides for itself, which is why a Latin item in a right-to-left combo still reads left to right.
-
baselineOffset
protected float baselineOffset()Mixed-step rows align on this, not on the box; seeFlex.CrossAlignment.BASELINE.- Overrides:
baselineOffsetin classWidget<ComboBox<T>>
-
onPaint
Description copied from class:WidgetWidget's own background/content, in local coordinates. -
onMouseEvent
Description copied from class:WidgetMouse events (bubbling); callevent.consume()when handled.- Overrides:
onMouseEventin classWidget<ComboBox<T>>
-
onCanEdit
Description copied from class:WidgetWhether this widget can do an editing command now: copy with something selected, paste with something to paste, undo with something to take back.Scene.canEdit(limn.scene.EditCommand)asks the widget that has the keyboard and then each of its ancestors, and a menu's item of an editing role is enabled by the answer.A widget answers for the commands it takes from the keyboard, and does for the command what it does for the key.
-
onEdit
Description copied from class:WidgetDoes an editing command, as the user's own act. Called on the first widget, from the one with the keyboard upward, whoseWidget.onCanEdit(limn.scene.EditCommand)answeredtrue. -
onKeyEvent
Description copied from class:WidgetKey events (focused widget first, then ancestors).- Overrides:
onKeyEventin classWidget<ComboBox<T>>
-
onCharTyped
Type-ahead: letters typed into an open list jump to what they spell, the way a combo does on Windows and a pop-up button does on GTK and macOS. Without it the only way through a long clamped list is one arrow press per item.Two behaviours a user expects and neither of which falls out of plain prefix matching. The buffer expires after
TYPE_AHEAD_RESET_NANOS, so "so" typed slowly is two separate jumps rather than a search for "so": a pause means a new word. And repeating one letter cycles through the items starting with it instead of re-finding the first, which is how a list of six things beginning with S is navigated at all.The search wraps and starts after the current highlight, so a match already under the cursor is not what a fresh keystroke finds.
- Overrides:
onCharTypedin classWidget<ComboBox<T>>
-
onFocusGained
protected void onFocusGained()Description copied from class:WidgetCalled when this widget takes keyboard focus. Default: nothing.- Overrides:
onFocusGainedin classWidget<ComboBox<T>>
-
accessibleLabelTarget
An editable combo's caption names its editor, where the caret and the reader are.- Overrides:
accessibleLabelTargetin classWidget<ComboBox<T>>- Returns:
- the widget that carries a label bound to this one;
thisby default - See Also:
-
onLayout
protected void onLayout()Description copied from class:WidgetContainers position children here (measure +Widget.layoutBox(float, float, float, float)per child). -
onFocusLost
protected void onFocusLost()Description copied from class:WidgetCalled when this widget loses keyboard focus. Default: nothing.- Overrides:
onFocusLostin classWidget<ComboBox<T>>
-
onDetached
protected void onDetached()A combo removed from the tree must never strand its dropdown on screen: a programmatically-opened popup has no focus to lose, so focus-lost alone does not cover this.- Overrides:
onDetachedin classWidget<ComboBox<T>>
-
onAccessibility
The field, which is a combo box that is open or shut and is showing one of its items. The options are not here: they are drawn by the panel and described by it, in whichever scene that panel is mounted in, which is what keeps their rectangles right in both presentations.The selected item is the value and never the name. A combo has no caption of its own — its items are values and not a label — so the name is left for an application's
setAccessibleNameor for the tooltip default to supply, and a combo with neither is published unnamed. Naming it from the item it shows would be worse than that: the name would change on every pick, and on the one platform that maps a name and a value to different attributes a reader would hear the same word twice for every combo in the interface.The number is what carries the text. The publish step builds a value facet only for a node that declared a number, so the selected item's text alone would be dropped in silence; and the difference raises its value event off the number and never off the text, so a constant standing in for one would make every pick silent on the channel a reader listens to. The index is the honest number — nothing else about the selection is ordered — and declaring it is also what advertises
SET_VALUE, which is how an assistive technology picks an item without opening the list at all.Nothing here is formatted. The item's text comes from the
I18nStringthe combo already holds, through that string's own per-language memo, so a hover fade or a focus fade — each of which damages this widget on every frame it lasts — walks this hook without allocating anything to conclude that nothing moved.- Overrides:
onAccessibilityin classWidget<ComboBox<T>>- Parameters:
a- the builder for this node
-
onAccessibilityAction
Opens the list, closes it, or picks an item, each through the path the user's own gesture takes.No enabled check of its own, unlike the panel's: the node acted on here is this widget, so the scene's own gate has already walked this field and every ancestor for
isEnabled(), checked that it is showing, that the window is not modal-blocked and that it is inside the layer that owns input. That last test is why aAccessible.Action.COLLAPSEsent to an open in-scene list does nothing, and why the walk does not publish one there: the list's own overlay is that layer, the field is behind it, and the dismissal that lands there is the overlay'sCANCEL— the same asymmetry the keyboard has, where Esc is delivered to the overlay and handed back here.- Overrides:
onAccessibilityActionin classWidget<ComboBox<T>>- Parameters:
action- what is being askedarg- the item to select forSET_VALUE, by number or by text- Returns:
- whether this widget did it
-