Arthur Schwarz wrote:
I do have a question. It's simple (for you) and bugging (me). How do I trap
events in my code? Example:

Control.pl calls Control::Package.

All windows are created in Control::Package.

All event sub's are located in Control::Package.

In particular, my $TopMenu = new Win32::GUI::Menu( # Main Window Menu
       'File'                 => 'TopMenuFile',
       '>&Open'               => 'TopMenuOpen',
       '>&New'                => 'TopMenuNew',
  );

and 'TopMenu*_Click' are located in Control::Package.

And won't be found. If using the event model that calls subs by name ('Original' event model - OEM), then the named subs must be in package main. To do what you're trying to do here you must use the 'New' event model, or NEM.

Win32::GUI::Dialog(); # is located in Control::Package.

But, clicking on a menu item isn't captured by the *_Click (or *_click) sub.

I know, I know. I shouldn't ask dumb questions, but???

(all code here untested)
package Control::Package;

my $TopMenu = Win32::GUI::Menu->new(
    'File'    => 'TopMenuFile',
    '>&Open   => { -name => 'TopMenuOpen', -onClick => \&Open },
    ....
);

sub Open {
  ...
};

Regards,
Rob.

Reply via email to