I'm trying to get a hierarchical submenu to popup in this example.
Interestingly, the keyboard shortcuts in the popup work OK. And
a trace shows that the handle() sub of Menus.pm gets called during
the keyboard shortcut processing.

However, the mouse selection of the menus doesn't work. And that
call to handle() in Menus.pm doesn't happen. Anyone have any
ideas on this one?

Regards,

Jake Commander

#!perl
use Mac::Windows;
use Mac::Events;
use Mac::Controls;
use Mac::Menus;

$wr = Rect->new(75, 75, 475, 250);
$win = MacWindow->new($wr, 'WinTitle', 1, floatProc(), 1);

my $m1 = MacHierMenu->new(2048, 'Test Menu', (
[ 'Submenu',           # title
undef,                 # event handler (null)
chr(27),               # shortcut keystroke
chr(221)],             # ID of $m2 sub-menu
[],                    # adds divider line
[ 'Item W',            # title
\&evthdlrW,            # event handler
'W'],                  # shortcut keystroke
));

my $m2 = MacHierMenu->new(221, 'Submenu', (
[ 'Item A',            # title
undef,                 # event handler (null)
'A'],                  # shortcut keystroke
[ 'Item B',            # title
\&evthdlrB,            # event handler
'B'],                  # shortcut keystroke
));
$m1->insert();
$m2->insert();

$cr = new Rect 10, 10, 230, 30;
$c = $win->new_control($cr,'PopTitle', 1, popupVariableWidth,
                       2048, 60, popupMenuProc
                                           );
$c->sethook('hit', sub {
     print GetControlValue($c->{control}), "\n";
     }
);

sub evthdlrW { print "evthdlrW called\n" }
sub evthdlrB { print "evthdlrB called\n" }

WaitNextEvent() while ($win->window()) ;
END {
  $win->dispose if (defined($win));
  $m1->dispose if (defined($m1));
  $m2->dispose if (defined($m2));
  DisposeControl($c->{control}) if defined $c;
}

Reply via email to