[haiku-development] Re: Menu shortcuts without Command key

  • From: Ryan Leavengood <leavengood@xxxxxxxxx>
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Wed, 9 Sep 2009 16:45:28 -0400

On Wed, Sep 9, 2009 at 4:31 PM, Kate <rogueeve@xxxxxxxxxxxxx> wrote:
> Is there any way to create a menu shortcut (hotkey) which does not require
> Command/Alt to be pressed to activate it. e.g. for an IDE, I want the "build
> and run" command to be F7. According to the Be Book this is impossible
> because Command is already set in the modifiers mask by default.

Yes currently it is not possible to make a single key shortcut with
BMenuItem. I don't necessarily agree with this limitation, but I know
at least Rene who responded before is STRONGLY against making it easy
to use single key shortcuts.

Of course it is possible and fairly easy to respond to whatever key
you want by overriding KeyDown in a particular view, or creating a
message filter to capture events for the whole app. If you really want
to be able to show those single key shortcuts in menu items you would
need to create a BMenuItem subclass (probably, it may not be trivial
due to the less than ideal design of the menu system which we
inherited from BeOS.)

> While I
> appreciate the elegance of always knowing that all menu commands will be
> under Command, this strictness seems a bit surprising to me. Something like
> "build and run" will be pressed thousands and thousands of times over the
> course of a program cycle. It makes it a bit harder on the user to have to
> push e.g. "ALT+R", and makes it tempting to try to implement hacks such as
> catching the F7 myself (but then how would I make it show up in the menu).

Well the argument could be made that having to reach up to the
function keys is harder than just holding Alt and hitting R without
having to move the fingers far from the home row. And I don't know if
i would call it a hack to add a message filter or override KeyDown. It
might be best to have your standard shortcuts use the command key and
then have advanced shortcuts (F7, etc) which your users can read about
in the user guide for your application.

Of course for what it is worth I agree with you that it shouldn't be
so hard to make single key shortcuts, but I may be a minority among
Haiku developers.

-- 
Regards,
Ryan

Other related posts: