Thanks for the help with popup menus Chris.

> Here's something I found on the list:
>    http://bumppo.net/lists/macperl-toolbox/2000/10/msg00001.html

That revealed the trick. Below is a variant which also works. I'm trying to
get a submenu of the popup to work too. I'll post an attempt separately.

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

$w_r = Rect->new(75, 75, 275, 225);
$win = MacWindow->new($w_r, 'WinTitle', 1, floatProc(), 1);
$menuID = 2048;

$m1 = MacHierMenu->new($menuID, 'MenuTitle');
$m1->add_item('A');
$m1->add_item('B');
$m1->add_item('C');
$m1->insert;

$c_r = new Rect 10, 10, 230, 30;
$c = $win->new_control($c_r,'PopTitle', 1, popupVariableWidth,
                       $menuID, 60, popupMenuProc
                                           );
SetControlValue($c->{control}, 2);
$c->sethook('hit', sub {
    $choice = GetControlValue($c->{control});
    MacPerl::Answer($choice);
    }
);

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

# NB The rectangle for the popup does not do quite what you'd expect:
#       the bottom determines the height position of "title";
#       the top seems to do nothing, but presumably should allow enough room;
#       the left side determines the start of the "title" field;
#       the right side limits the rightmost end of the popup;
#       the end of the "title" field is determined by param 6;
#       the width of the popup is determined by the longest string.
# (Thanks to <ajf(at)afco.demon.co.uk>)

Reply via email to