-postcommand and cascaded menus 
Author Message
 -postcommand and cascaded menus

I am having difficulty figuring out a good way to do the

When a user clicks on a menu, the GUI will automatically
search a set of files and populate info. from each file into a
cascaded menu label dynamically, and perform a callback when that
label is clicked on.

I have tried to do all of this with -postcommand, and the sub-labels
DO get populated, but the callback is immediately invoked, even
if the user didn't click on ANY sub-menu item.  In the snippet below,
everything in the innermost sub { } is executed as soon as the user
drags the mouse to the "Save Test Suite" label.  It should NOT be
executed until the user clicks on one of the sub-labels of
"Save Test Suite" that are populated dynamically.  
I must be overlooking something or making this more complex than it
needs to be.  Any ideas how to correct this?

TIA.  If responding via e-mail, replace the domain with

my $save_cascade = $menu3->cascade('-label' => 'Save Test Suite',
                                   '-tearoff' => 0);
$save_cascade->menu()->configure('-postcommand' =>
    sub { local $test_suite_ref, $listref, $description,
          $runlist_ref, $new_desc, $filename;
          $save_cascade->menu()->delete(0, 'end');

            $description = $test_suite_ref->[0]{description};
            $filename = $test_suite_ref->[0]{filename};
            # Populate the sub-labels dynamically
            $save_cascade->menu()->command('-label' => $description,
              '-command' =>
              sub { # Open the selected file and overwrite
                    # its contents with a new user description
                    # and list of scripts to run
                $new_desc = \&get_user_description();
                $runlist_ref = \&get_script_runlist();
                $listref = [{"filename" => $filename,
                             "description" => $new_desc,
                             "data" => $runlist_ref }];
                if(store($listref, "$ENV{HOME}/$filename")) {
                  print "\nSuccessful store into $filename\n";
                } else {
                  print "\nUnsuccessful store into $filename\n";
        } # end foreach
        # Additional menu item to save to a new file - it will be
        # included in the dynamically generated list above the next
        # time the menu is clicked
        $save_cascade->command('-label' => "Save new test suite",
                               '-command' => \&save_new_test_suite());

Wed, 21 Aug 2002 03:00:00 GMT  
 [ 1 post ] 

 Relevant Pages 

1. menu options not propagated to cascade menus?

2. cascade menu

3. Cascading Menus

4. help with cascaded menus and stuff...

5. menu cascade

6. referencing items on cascade menu?

7. problems with cascade menu

8. Multi level cascaded menus?

9. Cascade Menus

10. Multiple Menu cascades?

11. Cascading menu not responding to mouse...?? Code included

12. Cascading RadioButton Menu


Powered by phpBB® Forum Software