Skip to main content

Multi-Selection API

The Multi-Selection API provides a powerful system for handling complex selection scenarios including range selection, keyboard navigation, and box selection.

Overview

The multi-selection system works through BeginMultiSelect() and EndMultiSelect() functions that return an ImGuiMultiSelectIO structure containing selection requests to apply to your data.

Basic Workflow

Basic Example

Selection Storage

ImGuiSelectionBasicStorage

A helper class that stores selection state:

Custom Storage Adapter

For custom storage (e.g., storing indices in a vector):

Multi-Select Flags

Customize selection behavior:

Example with Flags

Using with Clipper

For large lists, combine with ImGuiListClipper for efficient rendering:
When using ImGuiListClipper:
  • Always check ms_io->RangeSrcItem and ensure it’s submitted (use clipper.IncludeItemByIndex())
  • The range source item must never be clipped or range selection won’t work correctly

Selection with Deletion

Handle item deletion while maintaining selection:
Deletion best practices:
  • Set ms_io->RangeSrcReset = true after deleting selected items
  • Clear or update NavId tracking if necessary
  • Iterate backwards when deleting from vectors

Multi-Selection in Tables

Per-Item Selection State

Check if an individual item was toggled:

Selection Requests

Understand the request types returned in ImGuiMultiSelectIO:

Manual Request Processing

Complete Example

Reference