At 5:40 pm -0500 19/04/02, Alex Harper wrote:

>At one point Alan Fry indicated to me on this list that Mac::Menus could
>only handle menu IDs in the 128-255 range (actually he suggested 200-255
>was the safest). As I recall he indicated that this was due to a bug in
>Menus.xs, but for the life of me I can't find the mail (Google search of
>the old bumppo.net archive is no help).

The extract Chris found:

>>  The 'tutorial' script below gives an example with some notes. Two
>>  other details come to mind:
>>
>>  a)  the popup ID must be capable of representation by an ASCII
>>  character -- i.e. in the range 0-255 (taking care not to
>>  trample on some other existing ID)
>>
>>  b)  the need for the line "InsertMenu(HANDLE, -1)", which is not
>>  documented anywhere I think.

is correct I think.

Popup menus are odd beasts being part 'Menu' and part 'Control'. In 
particular the manner in which the popup is built as a control is 
somewhat convoluted and not altogether satisfactory. If you look in 
'DialogBuilder' (on my site see below) you will find examples of 
scripts using 'popups' which you might find helpful.

Menus generally (in the MenuBar) take ID's in the range from 128 
(which is always the 'Apple' Menu) to 65535. Again the problem is to 
avoid trampling on an existing menu ID. David Seay some time ago 
suggested doing a loop of the kind:

use Mac::Menus;

     for my $m (128..65535) {
         $menuHandle = GetMenuHandle($m);
         if($menuHandle) { ... ID in use ....}
     }

and that is probably the safest thing to do. The difficulty is you 
never know what things other people have in their Menu Bars, (like 
'FreePPP' for instance). These 'third party' applications usually use 
highish Menu ID's reflecting their attempts to avoid stepping on some 
other apps' toes.

However beware of a trap. The loop will only return handles for Menus 
that are currently in the MenuBar. For instance it will never return 
the handle for MacPerl's 'Script' Menu, since that is always removed 
(by MacPerl) when the script runs.

So far as I am aware there are no bugs in Menus.pm. Some of the 
'popup' options (Controls.pm) didn't work in MacPerl 5.2.1a1 -- I 
regret I haven't got around to looking at 'Menus.pm' in MP 5.6.1r1 
yet.

There are some mis-attributions in the Controls.pm 'pod'. For 
instance 'popupFixedWidth' is listed as for use in the 'value 
parameter of the control creation' whereas it should be 'anded' with 
the 'control definition'.

As I said it's all a little convoluted...

HTH,

Alan Fry
<http://www.afco.demon.co.uk>


Reply via email to