>At 5:02 pm +0100 20/11/00, Greenblatt & Seay wrote: > >>Is the following code what you want? >> >>#!perl >> >>use Mac::Menus; >> >> for $m (128..3000) { >> $menuHandle = GetMenuHandle($m); >> if($menuHandle) { >> $menu = GetMenuBar(); >> print "$m = $menu -- $menuHandle\n"; >> } >> } >> >>__END__ > >Many thanks for your thoughts. Yes, of course -- loop through all >possible Menu ID's to see if a menuHandle is defined. (Like all good >ideas obvious when someone points it out.) > >The results pose some more puzzles however. A print out of ID, >$menuHandle->enableFlags and $menuHandle->menuData produces this for >a MacWindow: > > 128 11011111111111111111111111111111 chr(20) > 129 11101110011010100000000000000000 File > 130 10000101011001010000000000000000 Edit > 131 11011111111111111111111111111111 Window > 201 11111111111111111111111111111111 > 202 11111111111111111111111111111111 > 203 11111111111111111111111111111111 > 204 11111111111111111111111111111111 > 205 11111111111111111111111111111111 > 206 11111111111111111111111111111111 > >The first is the Apple Menu I think, but what does the chr(20) in the >Data field represent? It doesn't seem to be the Icon ID. In the Chicago font chr(20) is the apple character that is used for the menu name. > >Why is the 'Help' Menu not in the list and why are all other Menus to >the right of it (e.g. Finder at the far end) ignored I wonder? (By >contrast ClearMenu() zaps the lot.) Try expanding the loop... #!perl use Mac::Menus; $~="OUT1"; for $id (128..66000) { $menuHandle = GetMenuHandle($id); if($menuHandle) { # $menu = GetMenuBar(); $flags = $menuHandle->enableFlags; $data = $menuHandle->menuData; write; } } $~="STDOUT"; format OUT1 = @>>>> = @<<<<<<<<< @<<<<<<<< $id, $data, $flags . __END__ On my mac this yields... 128 = chr(20) -5 129 = File 18167 130 = Edit 44793 131 = Window -1 132 = Script -545 133 = Alpha 23 201 = -1 202 = -1 203 = -1 204 = -1 205 = -1 206 = -1 48981 = L-t -5 49046 = TU( -69 49047 = Tqî -9 65664 = chr(20) -5 65665 = File 18167 65666 = Edit 44793 65667 = Window -1 65668 = Script -545 65669 = Alpha 23 65737 = -1 65738 = -1 65739 = -1 65740 = -1 65741 = -1 65742 = -1 Checking out the System file's 'MENU' resource with ResEdit it appears that ID 49046 is the help menu. I have FreePPP installed and it has a menubar icon just to the left of the help menu. I'm guessing ID 48981 is for this and ID 49047 is for the far right menu that facilitates jumping to the Finder or other open applications. The following code lists the 'MENU' resorces for the MacPerl application... #!perl5 use Mac::Memory; use Mac::Resources;use Mac::MoreFiles; $programPath = $Application{McPL}; # MacPerl &read_resource; exit(0); sub read_resource { my $refnum = FSpOpenResFile($programPath, 1); for $resID (128..66000) { $handle = Get1Resource('MENU',$resID); if( $handle) { $info = $handle->get; $len = unpack("\@14 C1",$info); $menuName = unpack("\@15 a$len",$info); if($menuName) { print "$resID = $menuName\n" } } } CloseResFile $refnum; } __END__ On my Mac this yields... 128 = chr(20) 129 = File 130 = Edit 131 = Window 132 = Script 133 = Editor 192 = Type 65664 = chr(20) 65665 = File 65666 = Edit 65667 = Window 65668 = Script 65669 = Editor 65728 = Type > >Where do Menus 201->206 come from and why are all the 32 flags set to >1? Why is the Data field empty in each case? (RezEdit for MacPerl has >nothing to say about Menus with these ID's.) > >Any further thoughts? In particular what is the cast-iron rule for >determining what Menus are actually up and running? At first sight it >would seem any negative 'enableFlags' number might correspond to a >disabled Menu, but then the Apple Menu (very much alive and kicking) >returns -5. > >Alan Fry > David Seay http://www.mastercall.com/g-s/ ==== Want to unsubscribe from this list? ==== Send mail with body "unsubscribe" to macperl-toolbox-request@macperl.org