[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] justifying command key equivalent hints in menus



At 20.34 -0500 1998.12.23, Greenblatt & Seay wrote:
>$m="\$menu = new MacMenu 2048, \"$options[0]\", \(\n";
>for ($z = 1;$z < @options;$z++) { $m .= "    \[\"$options[$z]\"\,
>\\&Handler\]\,\n" }
>eval "$m\)";

Try this instead:

  $menu = MacMenu->new(2048, $options[0],
    map {
      my @a = split /\s+/, $_;
      $a[1] =~ s///;
      [$a[0], \&Handler, $a[1]]
    } @options[1..$#options]
  );

i.e., you end up with:

  $menu = MacMenu->new(2048, 'Ordinal',
    ['First',  \&Handler, '1'],
    ['Second', \&Handler, '2'],
    ['Third',  \&Handler, '3'],
    ['Fourth', \&Handler, '4']
  );

The third parameter is the shortcut keystroke.  You don't need to provide
that in the first parameter.

--
Chris Nandor          mailto:pudge@pobox.com         http://pudge.net/
%PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10  1FF77F13 8180B6B6'])

***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch