Skip to main content

Selectable Widgets

A selectable highlights when hovered, and can display another color when selected. Neighbors selectable extend their highlight bounds in order to leave no gap between them.

Selectable

Selectable widget. selected carries the selection state (read-only). Returns true when clicked.
const char*
Selectable label
bool
default:"false"
Current selection state (read-only)
ImGuiSelectableFlags
default:"0"
Selectable flags (see ImGuiSelectableFlags_)
const ImVec2&
default:"ImVec2(0, 0)"
Size (0.0f = use remaining width/height, >0.0f = specify)
bool
True when clicked (modify your selection state)

Selectable (pointer)

Selectable with pointer to selection state (read-write), as a convenient helper.
const char*
Selectable label
bool*
Pointer to selection state (read-write)
ImGuiSelectableFlags
default:"0"
Selectable flags
const ImVec2&
default:"ImVec2(0, 0)"
Size
bool
True when clicked

Multi-Selection

Multi-selection system for Selectable(), Checkbox(), TreeNode() functions. This enables standard multi-selection/range-selection idioms (Ctrl+Mouse/Keyboard, Shift+Mouse/Keyboard, etc.).

BeginMultiSelect

Begin multi-selection scope.
ImGuiMultiSelectFlags
Multi-select flags (see ImGuiMultiSelectFlags_)
int
default:"-1"
Current number of selected items (-1 if expensive to compute)
int
default:"-1"
Total number of items (-1 if expensive to compute)
ImGuiMultiSelectIO*
Multi-select I/O structure with requests to apply

EndMultiSelect

End multi-selection scope.
ImGuiMultiSelectIO*
Multi-select I/O structure with post-loop requests

SetNextItemSelectionUserData

Set selection user data for the next item. This is typically an item index within your current view.
ImGuiSelectionUserData
User data (typically item index)

IsItemToggledSelection

Was the last item selection state toggled? Useful if you need the per-item information before reaching EndMultiSelect().
bool
True if item selection was toggled

Selectable Flags

ImGuiSelectableFlags_

Flags for Selectable().

Multi-Select Flags

ImGuiMultiSelectFlags_

Flags for BeginMultiSelect().

List Boxes

List boxes are thin wrappers around BeginChild() with the ImGuiChildFlags_FrameStyle flag.

BeginListBox

Open a framed scrolling region. Only call EndListBox() if BeginListBox() returns true.
const char*
List box label
const ImVec2&
default:"ImVec2(0, 0)"
Size (0 = default size)
bool
True if list box is open

EndListBox

Close list box. Only call if BeginListBox() returned true.

ListBox (simple)

Simple list box helper.
const char*
List box label
int*
Pointer to current selected item index
const char* const[]
Array of item strings
int
Number of items in array
int
default:"-1"
Height in number of items (-1 = default ~7)
bool
True when selection has been modified

ListBox (callback)

List box with callback to get item strings.
const char*
List box label
int*
Pointer to current selected item index
const char* (*)(void*, int)
Callback function to get item string
void*
User data passed to callback
int
Number of items
int
default:"-1"
Height in number of items
bool
True when selection has been modified