class

Opal::UI::Dropdown

Inherits Opal::UI::Control < Opal::UI::InputHookable < Opal::UI::Element < Opal::UI::Themable < Reference < Object

Interactive Dropdown / Select control. Displays the current selection in a collapsed box and expands into a scrollable popup list on activation. Automatically flips orientation upwards if positioned near the bottom of the screen.

Constructors

new(items : Array(String), selected_index : Int32 = 0, placeholder : String = "Select...", expanded : Bool = false, max_visible_items : Int32 = 6, on_change : Proc(Int32, String, Nil) | Nil = nil, style : DropdownStyle = DropdownStyle::Classic)
Source
new(items : Array(String), selected_index : Int32 = 0, placeholder : String = "Select...", expanded : Bool = false, max_visible_items : Int32 = 6, &block : Int32, String -> Nil) : Dropdown
Source

Instance methods

arrow_down_glyph
Source
arrow_down_glyph=(arrow_down_glyph : String | Nil)
Source
arrow_glyph
Source
arrow_glyph=(g : String | Nil)
Source
arrow_up_glyph
Source
arrow_up_glyph=(arrow_up_glyph : String | Nil)
Source
border
Source
border=(b : Border | Nil)
Source
border_fg
Source
border_fg=(border_fg : Color | Nil)
Source
border_style
Source
border_style=(border_style : Border | Nil)
Source
close
Source
expanded=(expanded : Bool)
Source
expanded?
Source
filtered_items
Source
handle_key(key : Terminal::KeyEvent) : Bool

Default key event handler. Override in subclasses if not using @default_input_proc.

Source
handle_mouse(event : Terminal::MouseEvent) : Bool

Default mouse event handler. Override in subclasses if not using @default_input_proc.

Source
items
Source
items=(items : Array(String))
Source
max_visible_items
Source
max_visible_items=(max_visible_items : Int32)
Source
normal_bg
Source
normal_bg=(normal_bg : Color | Nil)
Source
normal_fg

Manipulable theme properties and character swaps

Source
normal_fg=(normal_fg : Color | Nil)

Manipulable theme properties and character swaps

Source
on_change
Source
on_change
Source
on_change=(on_change : Proc(Int32, String, Nil) | Nil)
Source
open
Source
placeholder
Source
placeholder=(placeholder : String)
Source
preferred_size(available_w : Int32, available_h : Int32) : Tuple(Int32, Int32)
Source
render(buffer : Buffer, x : Int32, y : Int32, width : Int32, height : Int32) : Nil
Source
scroll_offset
Source
scroll_offset=(scroll_offset : Int32)
Source
search_query
Source
search_query=(search_query : String)
Source
select(index : Int32) : self

Convenience alias

Source
select_index(index : Int32) : self

Sets selection by index, updating scroll position and firing callback

Source
selected_bg
Source
selected_bg=(selected_bg : Color | Nil)
Source
selected_fg
Source
selected_fg=(selected_fg : Color | Nil)
Source
selected_index
Source
selected_index=(selected_index : Int32)
Source
selected_item

Returns the currently selected item label, or placeholder if empty

Source
style
Source
style=(style : DropdownStyle)
Source
toggle

Toggles popup open/closed

Source