Luca Jovine writes Sun, 2 Aug 1998 11:56:27 +0100 (BST): >There are two things I would like to know how to implement, a serious one >(1) and a not-so-crucial one (2): > >(1) I would like to build a window which includes several popup menus > (each including the same list of items) and, next to each of them, > a text edit box where the user can enter a numerical value that has > to be associated to the item picked from the corresponding popup > menu. > > For example, each popup menu might display: chemical A > chemical B > chemical C > chemical D > ... > etc. You can create a new menu (with an ID 2048) like this: use Mac::Menus; $m1 = MacMenu->new(2048, 'TITLE'); $m1->add_item('chemical A', \&handler); $m1->add_item('chemical B', \&handler); which can be inserted into the menu bar by '$m1->insert'. To make the menu into a _popup_ (with Controls.pm) I believe you should do the following: $c = $win->new_control( # where $win is the MacWindow handle $c_r, 'TITLE', 1, popupVariableWidth, 2048, $offset, popupMenuProc ); The position of the the popup is defined by the rect $c_r (created by Rect->new()). Its left end determines the start of the title string and its right end determines the end of the popup. The start of the popup is determined by $offset. The vertical position of the popup is determined by the bottom of $c_r. The third parameter is set to 1 for visible 0 for hidden. The fourth parameter is one of a selection given in the Menus.pm pod. The fifth parameter is the ID of the menu, 2048 in this example. The sixth parameter is the MacOS "popupMenuProc". However as far as I can see this does not actually work. If the above is preceeded by a statement '$m1->insert', The menu appears in the menu bar and also as a (dysfunctional) popup in the window. It seems (unless I am on the wrong track here) that something is broken. You might as an alternative make a list using Lists.pm. An item in the list can be 'selected' and the selection used in much the same way as a menu selection. use Mac::Lists; $list= $win->new_list( Rect->new(10, 10, 210, 110), #rectangle around the list Rect->new(0, 0, 1, scalar(@list_of_chemicals)), Point->new(200, 20), 0, 1, 1); foreach (@list_of_chemicals) { #('chemical A', 'chemical B',...) $list->set(0, $n, $_); $n++ } $list->list->selFlags( #prevent multiple and null selections $list->list->selFlags | lNoExtend |lOnlyOne |lNoNilHilite ); >(2) How do I create a window which automatically disappears after 3 > seconds, or after the user clicks anywhere in it (that is, a typical > "About" window of a Mac program)? You could do something like this: $start = TickCount(); ... $win->sethook('click', sub { $OK = 1 }); ... while($win->window and !$OK) { if(TickCount > $start + 180) { $OK = 1 } WaitNextEvent } I hope this is some help, Alan Fry ***** Want to unsubscribe from this list? ***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch