Module: reefvision.widgets.listbox
Source: ./reefvision/widgets/listbox.reef
Overview
reefvision.widgets.listbox — selectable list with optional scrollbar
object ListBox extends view.View. Keyboard: Up/Down/Page/Home/End; Enter marks activated. Mouse: wheel scrolls content; click selects a row; scrollbar track/thumb click and drag change the offset.
The scrollbar is composition inside draw (a Scrollbar field), not a Group child. Shown when count > visible_rows.
Usage: let lb = new listbox.ListBox(cell.rect(0, 2, 32, 8), 64, 8) let _ = lb.add_item("item") win.add(lb)
Objects
ListBox
Extends: view.View
Fields:
| Name | Type |
|---|---|
items |
[string] |
capacity |
int |
count |
int |
selected |
int |
offset |
int |
visible_rows |
int |
activated |
bool |
sb_dragging |
bool |
sb |
scrollbar.Scrollbar |
proc init(bounds: cell.Rect, capacity: int, visible_rows: int)
Methods:
override shared fn wants_focus(): bool
override shared fn captures_mouse(): bool
shared fn count(): int
shared fn selected(): int
shared fn offset(): int
shared fn visible_rows(): int
shared fn item(idx: int): string
exclusive fn add_item(text: string): bool
exclusive proc clear()
shared fn max_offset(): int
exclusive proc clamp_offset()
exclusive proc set_selected(idx: int)
exclusive proc ensure_visible()
exclusive proc scroll_by(delta: int)
Scroll the viewport by delta rows (does not require changing selection).
shared fn has_scrollbar(): bool
shared fn is_sb_dragging(): bool
shared fn activated(): bool
exclusive proc clear_activate()
override exclusive proc draw(buf: cell.CellBuffer, abs: cell.Rect, clip: cell.Rect, focused: bool, th: theme.Theme)
override exclusive fn handle_event(e: event.Event): view.EventResult
exclusive fn handle_mouse(e: event.Event): bool
Full mouse path: wheel, list click, scrollbar click/drag.
exclusive fn click_at(abs_bounds: cell.Rect, x: int, y: int): bool
exclusive proc set_offset_from_y(abs_bounds: cell.Rect, y: int)
exclusive fn offset_from_track_row(track_row: int, track_h: int): int
Functions
fn max_items(): int
fn is_left_press_evt(e: event.Event): bool
fn is_left_release_evt(e: event.Event): bool
fn is_left_drag_evt(e: event.Event): bool
Generated by reefc doc