DropdownElement

io.worxbend.tui.dsl.DropdownElement
final case class DropdownElement(options: Seq[String], selected: Int, state: DropdownState, onSelect: Int => Unit, maxVisibleRows: Int = ..., props: ElementProps = ..., floating: Seq[Element] = ..., outsidePassesThrough: Boolean = ...) extends Element

A collapsed option chooser: one row showing the option in force, and, while open, the whole option list floating beneath it as a bordered popup.

The difference from SelectElement is what happens with a long list. select steps one option per keystroke and never shows more than the current one, so choosing the thirtieth of forty options takes thirty keystrokes and the user cannot see what they are choosing between. A dropdown shows the list.

Keys while focused. Closed: Enter, Space or Down opens the list. Open: Up/Down move the highlight, Enter commits it through onSelect, Escape closes without changing anything, and Tab closes it on its way to the next control. Note that an open dropdown consumes Escape — an app that binds Escape globally will not see it while a list is showing, which is the same bargain any modal makes and the reason the highlight is not the committed value.

A click on the closed row opens the list; a click on an option commits it; a click anywhere else — the row itself included — closes the list without committing, and is spent on that: the control under the pointer does not also receive it, unless the dropdown is built with passThroughOutside. The wheel over the list moves the highlight.

The list is drawn through the frame root, the way PortalElement draws, so the node claims one row whether the list is open or not and nothing around it moves when it opens. The popup sits under the row when the frame has room for it there and above the row when it does not, and is clipped to the frame — never to the panel or pane the row sits in. Rendered outside a host, with no frame root to float through, the list paints in place under the row, clipped only by the buffer.

floating is the framework's slot: the focus pass hands back the decorated scrim and list nodes through it, so the mouse router can find the list where it was painted. Application code never sets it.

Attributes

Graph
Supertypes
trait Serializable
trait Product
trait Equals
trait Element
class Object
trait Matchable
class Any
Show all

Members list

Type members

Types

This node's own type, so a fluent extension gives back what it was handed: progressBar(0.5).fill.bare type-checks because .fill returns a ProgressBarElement, not an abstract Element. Every concrete node fixes it to itself with one line, type Self = ThatNodeType.

This node's own type, so a fluent extension gives back what it was handed: progressBar(0.5).fill.bare type-checks because .fill returns a ProgressBarElement, not an abstract Element. Every concrete node fixes it to itself with one line, type Self = ThatNodeType.

Attributes

Value members

Concrete methods

override def children: Seq[Element]

While the list shows: the click-outside scrim and then the list, in paint order, so the list is painted last and wins the pointer over the scrim. Both are children for event routing only — the node paints them itself, through the portal queue, because where they go is only known at render time.

While the list shows: the click-outside scrim and then the list, in paint order, so the list is painted last and wins the pointer over the scrim. Both are children for event routing only — the node paints them itself, through the portal queue, because where they go is only known at render time.

Attributes

Definition Classes
override def debugName: String

The factory-style name of this node — panel, button, scrollView — for the element-tree snapshot and any other diagnostic that has to say what a node is without reflecting over its class. Every node type declares its own; a decorator answers with the name of the node it wraps. The default is only there so a node added without one still renders — ElementTreeSnapshotSpec fails the build until the override is written.

The factory-style name of this node — panel, button, scrollView — for the element-tree snapshot and any other diagnostic that has to say what a node is without reflecting over its class. Every node type declares its own; a decorator answers with the name of the node it wraps. The default is only there so a node added without one still renders — ElementTreeSnapshotSpec fails the build until the override is written.

Attributes

Definition Classes

This dropdown with a click outside its open list not spent on closing it: the list closes and the click goes on to the control under the pointer, as if no list had been showing — for a toolbar of pickers where a click on the next picker should open it at once. Esc, Tab and a click on the row itself still close the list as before.

This dropdown with a click outside its open list not spent on closing it: the list closes and the click goes on to the control under the pointer, as if no list had been showing — for a toolbar of pickers where a click on the next picker should open it at once. Esc, Tab and a click on the row itself still close the list as before.

Attributes

def widget: Widget

Inherited methods

def accessibleName: String

What this node is called when it is announced — button Save, checkbox agree — before the interaction states ElementHost.accessibleLabel appends. Defaults to debugName; a node with a label of its own says it.

What this node is called when it is announced — button Save, checkbox agree — before the interaction states ElementHost.accessibleLabel appends. Defaults to debugName; a node with a label of its own says it.

Attributes

Inherited from:
Element
def pointerShape: Option[PointerShape]

The mouse pointer this node wants shown over it, when it wants one: the hand over a button or a link, the I-beam over a text field. None leaves the pointer as it is. An explicit .pointer(shape) on the node lands in props.pointerShape and takes precedence; the interactive nodes override this with their own default.

The mouse pointer this node wants shown over it, when it wants one: the hand over a button or a link, the I-beam over a text field. None leaves the pointer as it is. An explicit .pointer(shape) on the node lands in props.pointerShape and takes precedence; the interactive nodes override this with their own default.

Attributes

Inherited from:
Element
def productElementNames: Iterator[String]

An iterator over the names of all the elements of this product.

An iterator over the names of all the elements of this product.

Attributes

Inherited from:
Product
def productIterator: Iterator[Any]

An iterator over all the elements of this product.

An iterator over all the elements of this product.

Attributes

Returns

in the default implementation, an Iterator[Any]

Inherited from:
Product
def style(style: Style): Self

This element with style as its own — the content style on every node: a text's text, a list's body, a panel's children and inner area. A container's border is frameStyle instead. The fluent builders (.fg, .bold, .styled(...)) edit the same style rather than replacing it.

This element with style as its own — the content style on every node: a text's text, a list's body, a panel's children and inner area. A container's border is frameStyle instead. The fluent builders (.fg, .bold, .styled(...)) edit the same style rather than replacing it.

Attributes

Inherited from:
Element
def style: Style

Attributes

Inherited from:
Element