Skip to content

App commands and shortcuts defined once (exact-modifier dispatch, modal scope, menu binding) #125

Closed

Description

@samitbasu

A command has a title, a shortcut and an enablement; a menu item shows the shortcut and is disabled with it; one dispatcher respects modal scope. Two egui traps today: consume_shortcut matches modifiers logically, so ⌘S also fires on ⇧⌘S (reproduced, plain egui 0.37), and modal scope is manual.

Proposal: Commands<A> (id, title, shortcut, enabled: fn(&A) -> bool, run: fn(&mut A)), one dispatcher per frame matching modifiers exactly and stopping at the topmost modal root (M6c, #106); stock menu items take .command(id) (#109).

From the operator-console port (#22), at rev 855eb20; reproduced on Linux.

Activity

  1. added
    enhancement
    on Nov 11, 2026
  2. samitbasu commented on Nov 14, 2026

    @samitbasu
    OwnerAuthor

    Design approved (user, 2026-11-13):

    • While a text field has focus, only ⌘/Ctrl/Alt chords fire, minus the reserved editing set; a command can override this with .in_text(InText::Fire | InText::Yield).
    • Command ids are the app's own enum, via Key.
    • A disabled command's chord is not consumed and passes through.
    • The table is declared once with b.commands(table, app); per-root tables, so page commands don't fire under a modal; exact modifier matching.
      sonnet-1 is building on app-commands.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions