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:
1: Proceed, taking the default action defined for the event.
0: Proceed, but do not take the default action.
-1: Terminate the message loop.
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
[EMAIL PROTECTED]
>>> [EMAIL PROTECTED] 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
terminate. Anyone have any ideas why???
Thanks,
Louis
At 03:00 PM 6/27/2001 +0200, Johan Lindstrom wrote:
>Louis wrote:
>>$W = new Win32::GUI::Window(
>> -title => "Win32::GUI::Louis Test",
>> -left => 100,
>> -top => 100,
>> -width => 200,
>> -height => 150,
>> -font => $F,
>> -name => "Window",
>>);
>
>Note the -name.
>
>
>>sub W_Terminate {-1;}
>
>Note the name. You use the name of a variable you happened to assign the
>the object to. All event handlers are named after the -name option. This
>should work better:
>
>sub Window_Terminate {-1;}
>
>I often find that my event code never gets run and wonder why. Then I
>insert a little
>
> print "!";
>
>in the handler sub and find that the event is never triggered at all...
>Oops :/ It is almost always caused by a misspelling or misunderstanding
>of the control name.
>
>
>BTW, it may be a test thing, but "Window" is a lousy name for a lot of
>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öm Boss Casinos
>Sourcerer [EMAIL PROTECTED]
> http://www.bahnhof.se/~johanl/
>If the only tool you have is a hammer,
>everything tends to look
>like a nail
>
>
>_______________________________________________
>Perl-Win32-GUI-Users mailing list
>[email protected]
>http://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users
--
¤¤º°`°º¤ø, ,ø¤º°`°º¤øø¤º°`°º¤ø, ,ø¤º°`°º¤øø¤º°`°º¤
¤°`°Lightbridge, Inc
¤°`°67 South Bedford St.
¤°`°Burlington MA 01832
¤°`°781.359.4795 mailto:[EMAIL PROTECTED]
¤°`°http://www.lightbridge.com
¤¤º°`°º¤ø, ,ø¤º°`°º¤øø¤º°`°º¤ø, ,ø¤º°`°º¤øø¤º°`°º¤
_______________________________________________
Perl-Win32-GUI-Users mailing list
[email protected]
http://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users