Class ListBox
- Namespace
- PluginUI
- Assembly
- PluginUI.dll
Virtualized list of items (presets, files, samples...): only visible rows are drawn, so lists of any length cost the same per frame. Single or extended selection (Ctrl / Shift), keyboard navigation with type-ahead, wheel and slim scrollbar, double-click / Enter activation and optional drag reordering.
public class ListBox : Control
- Inheritance
-
ListBox
- Inherited Members
Remarks
Constructors
ListBox()
Creates an empty list.
public ListBox()
ListBox(IList)
Creates a list over items.
public ListBox(IList items)
Parameters
itemsIList
Properties
AllowReorder
Lets the user reorder rows by dragging (the Items list must be writable).
public bool AllowReorder { get; set; }
Property Value
Count
Number of items.
public int Count { get; }
Property Value
DefaultSize
Natural size used when no explicit size is given.
protected override Size DefaultSize { get; }
Property Value
DrawBackground
Draws the frame and background.
public bool DrawBackground { get; set; }
Property Value
EmptyText
Text shown when the list is empty.
public string? EmptyText { get; set; }
Property Value
ItemHeight
Row height in DIPs.
public float ItemHeight { get; set; }
Property Value
ItemRenderer
Custom row renderer (replaces the default text row; selection/hover backgrounds are still drawn).
[Browsable(false)]
public Action<DrawingContext, Rect, object, ListItemState>? ItemRenderer { get; set; }
Property Value
ItemText
Text of an item (default: ToString()).
[Browsable(false)]
public Func<object, string>? ItemText { get; set; }
Property Value
Items
Items (any list; strings are shown as is).
public IList? Items { get; set; }
Property Value
MultiSelect
Allows several selected rows (Ctrl+click, Shift+click, Shift+arrows, Ctrl+A).
public bool MultiSelect { get; set; }
Property Value
SelectedIndex
First selected index (-1 = none); setting it selects only that row and scrolls it into view.
public int SelectedIndex { get; set; }
Property Value
SelectedIndices
Selected indices in ascending order.
public IReadOnlyCollection<int> SelectedIndices { get; }
Property Value
SelectedItem
First selected item.
public object? SelectedItem { get; }
Property Value
Striped
Draws alternate row backgrounds.
public bool Striped { get; set; }
Property Value
Methods
LayoutParts(VectorStyle, out Rect, out Rect, out Rect)
Splits the bounds into label (top), widget and value (bottom) areas according to the style. Override to change the arrangement (e.g. label on the left for sliders).
protected override void LayoutParts(VectorStyle style, out Rect label, out Rect widget, out Rect value)
Parameters
styleVectorStylelabelRectwidgetRectvalueRect
OnCaptureLost()
The mouse capture was lost without a button release.
protected override void OnCaptureLost()
OnDragLeave()
Internal drag left this element.
protected override void OnDragLeave()
OnDragOver(DragEventArgs)
Internal drag over this element: set Accept to accept.
protected override void OnDragOver(DragEventArgs e)
Parameters
OnDrop(DragEventArgs)
Internal drop on this element.
protected override void OnDrop(DragEventArgs e)
Parameters
OnKeyDown(KeyEventArgs)
Key pressed while focused (bubbles to parents).
protected override void OnKeyDown(KeyEventArgs e)
Parameters
OnMouseDown(MouseEventArgs)
Mouse button pressed over the element (or captured).
protected override void OnMouseDown(MouseEventArgs e)
Parameters
OnMouseLeave()
The mouse left the element.
protected override void OnMouseLeave()
OnMouseMove(MouseEventArgs)
Mouse moved over the element (or captured).
protected override void OnMouseMove(MouseEventArgs e)
Parameters
OnMouseUp(MouseEventArgs)
Mouse button released.
protected override void OnMouseUp(MouseEventArgs e)
Parameters
OnMouseWheel(MouseEventArgs)
Mouse wheel over the element.
protected override void OnMouseWheel(MouseEventArgs e)
Parameters
OnRenderOverlay(DrawingContext)
Draws the keyboard focus ring.
protected override void OnRenderOverlay(DrawingContext dc)
Parameters
Refresh()
Re-reads the list after it changed (clamps the selection and the scroll position).
public void Refresh()
RenderVector(DrawingContext, Rect, VectorStyle)
Vector rendering of the widget area.
protected override void RenderVector(DrawingContext dc, Rect widget, VectorStyle style)
Parameters
dcDrawingContextwidgetRectstyleVectorStyle
ScrollIntoView(int)
Scrolls so that the row is visible.
public void ScrollIntoView(int index)
Parameters
indexint
TextOf(object?)
Text displayed for an item.
protected string TextOf(object? item)
Parameters
itemobject
Returns
Events
ItemActivated
Raised on double-click or Enter.
public event Action<ListBox, int>? ItemActivated
Event Type
ItemMoved
Raised after a drag reorder moved an item (from, to).
public event Action<ListBox, int, int>? ItemMoved
Event Type
SelectionChanged
Raised when the selection changes.
public event Action<ListBox>? SelectionChanged