Capture spacebar

  • I have an iTunes-like app and would like to use the spacebar for start/stop
    but only if there is not an active text field or other control that may need
    the space bar to act normally.

    How can I achieve this?

    Also, is there anyway to put [space] in the menu item command key - without
    the command modifier?

    Thanks,

    Trygve
  • On 17 Oct 06, at 23:48, Trygve Inda wrote:
    > I have an iTunes-like app and would like to use the spacebar for
    > start/stop
    > but only if there is not an active text field or other control that
    > may need
    > the space bar to act normally.
    >
    > How can I achieve this?
    >
    > Also, is there anyway to put [space] in the menu item command key -
    > without
    > the command modifier?

    In order:

    Best solution I know of is to subclass NSApplication and catch it in -
    [NSApplication sendEvent:].

    Add "        space" to the title of the menu item. There is, in fact,
    no other way to display it - this is what iTunes does as well.
  • > On 17 Oct 06, at 23:48, Trygve Inda wrote:
    >> I have an iTunes-like app and would like to use the spacebar for
    >> start/stop
    >> but only if there is not an active text field or other control that
    >> may need
    >> the space bar to act normally.
    >>
    >> How can I achieve this?
    >>
    >> Also, is there anyway to put [space] in the menu item command key -
    >> without
    >> the command modifier?
    >
    > In order:
    >
    > Best solution I know of is to subclass NSApplication and catch it in -
    > [NSApplication sendEvent:].
    >
    > Add "        space" to the title of the menu item. There is, in fact,
    > no other way to display it - this is what iTunes does as well.

    Will this ensure no other control wants the spacebar key since any text
    fields etc. should catch it before getting to this point?

    Thanks,

    Trygve
  • On 18 Oct 06, at 01:49, Trygve Inda wrote:
    >> On 17 Oct 06, at 23:48, Trygve Inda wrote:
    >>> I have an iTunes-like app and would like to use the spacebar for
    >>> start/stop
    >>> but only if there is not an active text field or other control that
    >>> may need
    >>> the space bar to act normally.
    >>>
    >>> How can I achieve this?
    >>>
    >>> Also, is there anyway to put [space] in the menu item command key -
    >>> without
    >>> the command modifier?
    >>
    >> In order:
    >>
    >> Best solution I know of is to subclass NSApplication and catch it
    >> in -
    >> [NSApplication sendEvent:].
    >>
    >> Add "        space" to the title of the menu item. There is, in fact,
    >> no other way to display it - this is what iTunes does as well.
    >
    > Will this ensure no other control wants the spacebar key since any
    > text
    > fields etc. should catch it before getting to this point?

    Yes. The default implementation (which you'll need to call from your
    subclass) is actually what's responsible for sending events everywhere
    else.
previous month october 2006 next month
MTWTFSS
            1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31          
Go to today