Hello menu controllers,
thanks for the hints. I found a solution now to disable
the MacPerl menus at runtime.
Your menu id checker doesn't give me the needed results though:
>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__
results in:
128 = -5
129 = File 22263
130 = Edit 44793
131 = Window -1
133 = BBEdit 23
201 = -1
202 = -1
203 = -1
204 = -1
205 = -1
206 = -1
207 = -1
208 = -1
45346 = -1
45537 = ".0 -4385
49046 = Hilfe -65
49047 = ��, -9
49056 = �� 524287
65664 = -5
65665 = File 22263
65666 = Edit 44793
65667 = Window -1
65669 = BBEdit 23
65737 = -1
65738 = -1
65739 = -1
65740 = -1
65741 = -1
65742 = -1
65743 = -1
65744 = -1
Menu id 132 for "Script" is missing. I can only guess why (Mercution?).
The following code (thanks Thomas) does what I originally wanted:
use Mac::Menus;
use Mac::Events;
@macperl_menus = (
128, # Apple
129, # File
130, # Edit
131, # Window
132, # Script
133, # Editor
);
print "disabling ...\n";
for ( @macperl_menus ) {
my $menu = GetMenuHandle $_;
if( $menu ) { DisableItem $menu; DisableItem $menu, 0; }
}
DrawMenuBar;
pause( 10 );
print "enabling ...\n";
for ( @macperl_menus ) {
my $menu = GetMenuHandle $_;
if( $menu ) { EnableItem $menu; EnableItem $menu, 0; }
}
DrawMenuBar;
print "done.\n";
exit;
sub pause {
my ($time) = @_;
my $start = time;
WaitNextEvent until time > ($start + $time);
}
__END__
Deleting with DeleteMenu $id works fine too.
Just in case - how could I easily restore it?
Regards,
Axel.