Skip to main content

Module shortcut_settings

Module shortcut_settings 

Source
Expand description

ShortcutSettings — user-facing widget for browsing and rebinding application shortcuts.

Reads every shortcut registered in the tree’s ShortcutRegistry and renders one row per entry, grouped by category, with both primary and secondary keystrokes independently rebindable. Supports:

  • Rebind (primary or secondary) via one-shot key capture.
  • Unbind a slot explicitly (sets the override to None), or press Delete / Backspace during capture.
  • Reset clears the user override entirely, restoring the declared defaults. Disabled when no override exists.
  • Conflict auto-resolution: rebinding to a keystroke already bound elsewhere silently unbinds the conflicting shortcut so there’s always exactly one binding per chord.
  • Escape during capture cancels without committing.
  • Platform-aware keystroke labels via format_keystroke.

The widget owns the currently-armed [CaptureHandle]; dropping the widget cancels the capture, so navigating away mid-rebind cannot leak a stray rebind onto the next keystroke pressed somewhere else in the app.

// Inside a settings Dialog build():
let filter = ctx.signal(String::new());
ctx.add(
    ShortcutSettings::new()
        .with_filter(filter)
        .confirm_conflicts(true)
        .on_conflict(|c| println!("displaced: {}", c.displaced_name)),
);

Structs§

ShortcutConflict
Describes a rebind that collides with an existing binding.
ShortcutSettings
A settings panel for browsing and rebinding application shortcuts.