gridSelection static method
KeyBindings
gridSelection({
- required void onUp(),
- required void onDown(),
- required void onLeft(),
- required void onRight(),
- void onToggle()?,
- bool showToggleHint = false,
- KeyActionResult onConfirm()?,
- void onCancel()?,
Creates 2D grid selection bindings (navigation + optional toggle + confirm + cancel).
Useful for multi-column selectors where arrow keys move the cursor and an optional space-bar toggle is exposed for selecting cells inline.
Implementation
static KeyBindings gridSelection({
required void Function() onUp,
required void Function() onDown,
required void Function() onLeft,
required void Function() onRight,
void Function()? onToggle,
bool showToggleHint = false,
KeyActionResult Function()? onConfirm,
void Function()? onCancel,
}) {
var bindings = gridNavigation(
onUp: onUp,
onDown: onDown,
onLeft: onLeft,
onRight: onRight,
);
if (onToggle != null) {
bindings = bindings +
KeyBindings([
KeyBinding.single(
KeyEventType.space,
(event) {
onToggle();
return KeyActionResult.handled;
},
hintLabel: showToggleHint ? 'Space' : null,
hintDescription: showToggleHint ? 'toggle selection' : null,
),
]);
}
return bindings +
confirm(onConfirm: onConfirm) +
cancel(onCancel: onCancel);
}