From: Andrew K. <aki...@gs...> - 2001-06-27 13:58:19
|
You can use either: sub W_Terminate {-1;} or sub Window_Terminate {1;} I admit I don't totally understand this since the documentation for = _Terminate() says: Sent when the window is closed. The event should return -1 to terminate the interaction and return control to the perl script; see Dialog() And the Win32::GUI tutorial says about Event Handlers: Event handlers should return one of three specific values:=20 1: Proceed, taking the default action defined for the event.=20 0: Proceed, but do not take the default action.=20 -1: Terminate the message loop.=20 I guess the second "version" is more correct since the Event Handler = should have the name of <window name>_<event name> despite the "should = return -1" in the documentation for _Terminate(); Andrew Kincaid Lead PC Systems Specialist, IS&T Georgia State University aki...@gs...=20 >>> lb...@li... 06/27/01 09:27AM >>> Thank you all. I found I had to add the following before the sleep to terminate the loop: exit(0) if !$W->IsEnabled(); And change my terminate sub to the following: sub Window_Terminate {-1;print "";} For some odd reason if I do not do a print the program will not=20 terminate. Anyone have any ideas why??? Thanks, Louis At 03:00 PM 6/27/2001 +0200, Johan Lindstrom wrote: >Louis wrote: >>$W =3D new Win32::GUI::Window( >> -title =3D> "Win32::GUI::Louis Test", >> -left =3D> 100, >> -top =3D> 100, >> -width =3D> 200, >> -height =3D> 150, >> -font =3D> $F, >> -name =3D> "Window", >>); > >Note the -name. > > >>sub W_Terminate {-1;} > >Note the name. You use the name of a variable you happened to assign = the=20 >the object to. All event handlers are named after the -name option. = This=20 >should work better: > >sub Window_Terminate {-1;} > >I often find that my event code never gets run and wonder why. Then I=20 >insert a little > > print "!"; > >in the handler sub and find that the event is never triggered at = all...=20 >Oops :/ It is almost always caused by a misspelling or misunderstanding= =20 >of the control name. > > >BTW, it may be a test thing, but "Window" is a lousy name for a lot of=20 >reasons, some actually important. I discuss this in The GUI Loft User = Manual: > ><http://www.bahnhof.se/~johanl/perl/Loft/manual.html#control%20names%20are= %20global> > > >/J > >------ ---- --- -- -- -- - - - - - >Johan Lindstr=F6m Boss Casinos >Sourcerer jo...@ba...=20 > http://www.bahnhof.se/~johanl/=20 >If the only tool you have is a hammer, >everything tends to look >like a nail > > >_______________________________________________ >Perl-Win32-GUI-Users mailing list >Per...@li...=20 >http://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users=20 -- =A4=A4=BA=B0`=B0=BA=A4=F8, ,=F8=A4=BA=B0`=B0=BA=A4=F8=F8=A4=BA=B0`=B0=BA= =A4=F8, ,=F8=A4=BA=B0`=B0=BA=A4=F8=F8=A4=BA=B0`=B0=BA=A4 =A4=B0`=B0Lightbridge, Inc =A4=B0`=B067 South Bedford St. =A4=B0`=B0Burlington MA 01832 =A4=B0`=B0781.359.4795 mailto:lb...@li...=20 =A4=B0`=B0http://www.lightbridge.com=20 =A4=A4=BA=B0`=B0=BA=A4=F8, ,=F8=A4=BA=B0`=B0=BA=A4=F8=F8=A4=BA=B0`=B0=BA= =A4=F8, ,=F8=A4=BA=B0`=B0=BA=A4=F8=F8=A4=BA=B0`=B0=BA=A4 _______________________________________________ Perl-Win32-GUI-Users mailing list Per...@li...=20 http://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users |