I've finally gotten a few moments to start playing around with my Mac GUI
again, and have been scouring Nandor's mp3player.plx (off pudge.net) for
tips and tricks. The first thing I'm working on is the menus. And I've
already run into a roadblock.

This is the code I'm using - except for removing some of the unneeded menu
items, and rolling a subroutine into the main code, it's pretty close to
what Nandor has in his mp3player.plx. Yet, I get the following on a syntax
check:

 # Splooge:Desktop Folder:menus.pl syntax OK
 # theMenu is not of type MenuHandle.
 File 'Splooge:Desktop Folder:menus.pl'; Line 49
 # END failed--cleanup aborted.

I can throw in a dummy window and run this script, however. Of course, the
menus never work (why don't they work? sniff, sniff), and the error appears
when I stop the script (as per END).

What am I doing wrong?

 #!/usr/bin/perl
 use Mac::Menus;
 use strict;

 my $oldEdit = GetMenuHandle(130);
 my $oldFile = GetMenuHandle(129);
 my $oldEditor = GetMenuHandle(133);

 my $newMenu = new_menu();
 my $newEdit = $$newMenu[0]->{menu};
 my $newFile = $$newMenu[1]->{menu};
 DeleteMenu(133);
 DeleteMenu(130);
 DeleteMenu(129);
 InsertMenu $newEdit, 133;
 InsertMenu $newFile, 2048;
 DrawMenuBar();
 DisableItem($newEdit, 1);
 DisableItem($newEdit, 2);
 DisableItem($newEdit, 3);
 DisableItem($newEdit, 4);

 sub new_menu {

   my $newFile = MacMenu->new ( 2049, 'File', (
                                ['Quit',   \&file_menu, 'Q'] ) );
   my $newEdit = MacMenu->new ( 2048, 'Edit', ( ['Cut',   \&edit_menu, 'X'],
                                                ['Copy',  \&edit_menu, 'C'],
                                                ['Paste', \&edit_menu, 'V'],
                                                ['Clear', \&edit_menu,  ''],
                                              )
                               );

   return [$newEdit, $newFile];
 }

 sub edit_menu { my ($menu, $item) = @_; 1; }

 sub file_menu {
   my ($menu, $item) = @_;
   if ($menu == 2049 and $item == 1) { exit; }
 }

 sub restore_menu_bar {
   DeleteMenu(2048);
   DeleteMenu(2049);
   InsertMenu($oldEdit,   133);
   InsertMenu($oldFile,   130);
   InsertMenu($oldEditor, 134);
   DrawMenuBar();
 }

 END { restore_menu_bar(); }

 __END__

Thanks for any help you can give me.

-- 
Morbus Iff
   ______       Here we have HomelessMorbus - living in a box. Able to
   | () |       furnish an old refrigerator box into a spacious 3 room
   |<\/>|      complete with Internet connection and entertainment center,
   |_/\_|       until it rains, and then he's up to his knees in shat...
                   Devil Shat: <http://www.disobey.com/devilshat/>

-01--- <\/> ---- <http://www.disobey.com/> --- Bad Ascii, Short Notice ----

Reply via email to