From: John, G. <gj...@qu...> - 2007-10-30 10:33:02
|
Hi, I'm trying to write the event handlers for menu item clicks. I have sub-classed Win32::GUI::Window to provide the main window for my application. This all works nicely, except that I've just added a menu to my main window and I can't seem to figure out how to access any object data from my _Click handlers. The program below reproduces this issue. What I would like is to be able to access the main window as $self in sub Exit_Click, but it's undefined. #!/usr/bin/perl -w package MyWindow; use Win32::GUI(); @MyWindow::ISA =3D qw (Win32::GUI::Window); sub new { my $proto =3D shift; my $class =3D ref($proto) || $proto; my %params =3D @_; $params{-menu} =3D Win32::GUI::Menu->new( "&File" =3D> "File", ">E&xit" =3D> "MyWindow::Exit", ); my $self =3D $class->SUPER::new(%params); bless $self, $class; return $self; }; sub Exit_Click { my $self =3D shift; print ref($self), "\n"; print "File->Exit Clicked"; return -1; } 1; package main; my $window =3D new MyWindow(-height =3D> 200, -width =3D> 300); $window->Show(); Win32::GUI::Dialog(); __END__ Is there any way to call the _Click event handlers as object methods rather than class methods? Cheers, Gareth John |