Skip to content

The big menu issue #152

Closed
Closed
@andlabs

Description

@andlabs

The current menu API is a huge kludge right now.

  • Only one menubar for the entire program; no way to make right-click menus
  • Menus and menu items can only be created until the first uiWindow is created
  • No way to specify accelerators
  • No way to specify mnemonics
  • Predefined About, Preferences, and Quit items for OS X, the last having a predefined handler due to the Dock icon's Quit item being nonprogrammable — and those aren't enough

OS X PROBLEMS

Everything is an informal protocol.

Many of the standard menu items, most notably in the Edit menu, work by sending a predefined selector, such as cut:, to the first responder. Things like NSTextField and NSTextView already implement all of this; we can do this in uiArea with a bunch of extensions to uiAreaHandler.

But all those items would need to be made predefined menu items, such as uiMenuAppendCutItem(). Maybe a macro would be better.

Also keyboard accelerators only work if tied to a menu item. Command+C for copy has to be on the Copy item. (Corollary: programmable accelerators would allow us to override these conventions. Should we? Right now the Application Menu is hardcoded to do Command+, be Preferences and Command+Q to be Quit, and Command+(Option+)H for the various Hide options.)

I want to eventually support the Document-Based Application framework. This might add a bunch more predefined menu items.

Unsure about:

  • File > Close is defaulted to performClose:, a NSWindow method which simulates clicking the Close button
  • Find/Replace all involve panels
  • Spelling/Grammar do too, plus we explicitly disable all that anyway
    • Substitutions too
  • the Fonts, Format, and Text menus operate antithetically to how we operate; in fact, so did the Font dialog (that's why we have uiFontButton)
    • on GTK+ and Windows, the font dialog is a MODAL thing
    • and again, all these items expect to use standard NSText selectors to do their thing, otherwise they would only work for our views
    • Text menu involves rulers, which we also don't support because only OS X provides them
  • Window menu:
    • fullscreen is NOT part of this menu (it's part of the View menu, if any) (and it also uses a NSWindow selector)
    • we need to take care not to put dialogs here on other platforms
    • in fact, on other platforms we have to do this ourselves (Windows does automate the process for its MDI but only for its MDI and its MDI is long deprecated)
  • Help: unlike other platforms, application name should be in the Help item name

There are also canonical text editing shortcuts handled by the text system. Relevant to the uiArea text discussion as well.

Finally, there's the global menubar. If we have per-window menus, we would need to watch when the key window changes to change the menubar...

GTK+ ISSUES

I'm not sure how copy/paste/etc. work. Is it keybinding signals or GtkAccelGroup? Or is it gtk_window_add_mnemonic()?

WINDOWS ISSUES

There is no standard editing interface, but there are some editing messages like WM_UNDO and WM_COPY. Unfortunately, the Edit control also provides its own which it prefers under some circumstances. Unfortunately unfortunately, there's nothing like WM_CANUNDO (as far as I know).

So we would need an interface for cut/copy/paste/etc. somehow.

Microsoft recommends against using Preferences, instead suggesting Options

IIRC can't have a hard tab in a menu label; that's how keyboard shortcuts work

So I'm not sure what to do. What kind of API would be better? It shouldn't be purely declarative as opposed to functional (declarative APIs can be written on top of non-declarative APIs easily, but not the other way around).

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions