[haiku-3rdparty-dev] Re: Menu Shortcuts..

  • From: Rene Gollent <anevilyak@xxxxxxxxx>
  • To: haiku-3rdparty-dev@xxxxxxxxxxxxx
  • Date: Fri, 14 Jun 2013 20:01:20 -0400

On 6/14/13, Matthew Allen <fret@xxxxxxxxxxxx> wrote:
> So in my reading of the BeBook's handling of BMenuItem shortcuts:
> - The B_COMMAND_KEY flag is assumed, and can't be "turned off".
> - Only alpha characters are support for the "key" part of the shortcut.

This part at least isn't entirely accurate. Arrows and various
non-alpha symbols/keys certainly work, and most of the non-printable
keys have constants for defining them such as B_ENTER (c.f.
headers/os/interface/InterfaceDefs.h from line 36 onwards).

> These don't need the M_COMMAND_KEY modifier. And don't seem to be supported
> anyway (I get little square boxes instead of F1 etc). In fact that
> restriction is quite specific to Haiku/Beos... no other OS forces you to
> have a modifier key.

Yes, this is an unfortunate a limitation of the R5 menu API. In
general it's not terribly well designed. In any case, as far as
handling non-standard/arbitrary shortcuts goes, probably the easiest
path is to override BWindow::DispatchMessage() and trap/handle
B_KEY_DOWN for those special cases there, as that will receive it
before any view ever does, and consequently the shortcut can be
handled uniformly regardless of what currently has input focus. This
won't solve the problem of being unable to display them in the menu
items, but for that I know of no easy workaround. Someone else may
though.

Hope that helps,

Rene

Other related posts: