Re: [perl-win32-gui-users] tutorials use strict? use warnings?
globals? sender and eventargs? $self?
From: <jez...@ho...> - 2008-02-21 14:37:10
|
Hi, Aquick reply. The tutorials are "bad" as they are really old. Have a look at the examples supplied as they are better formed. Yes you can wrap event handlers within an object so that each window knows its own "state". This allows you to create and destroy many windows of the same object type dyamically. To do this have a look at the UserData method. It allows you to associate data to a window. When you use NEM events the first parm is the object that the event fired on. Say for example you have a button on a form, and you have many instances of that form your even handler would look like: My $self=shift; #the button object My $parent = $self->parent; #the parent window My $object = $parent->UserData; #the instance data for the window If you search the mailing list you should come across examples. I don't have perl installed on this box - but this reply should have enough content to get you started. Cheers, jez --Original Message----- From: "David Christensen" <dpc...@ho...> To: "per...@li..." <per...@li...> Sent: 21/02/08 05:30 Subject: [perl-win32-gui-users] tutorials use strict? use warnings? globals? sender and eventargs? $self? perl-win32-gui-users: I'm a Win32::GUI newbie who went through the tutorials the other night: http://perl-win32-gui.sourceforge.net/cgi-bin/docs.cgi?doc=tutorial and was shocked to see: 1. No "use strict" nor "use warnings". 2. The scripts used global variables to pass around references to the windows, controls, etc.. 3. There were no sender or eventargs arguments. (Not even a $self arg?) RTFM, I don't see them either. Am I missing something? I was looking for an OO GUI toolkit in Perl. I intend to build an application that will feature pop-up forms for editing objects persisted in a database. My idea is to create a class and a table for each object type. The class includes a method to create and display a window for editing that type of object. When the user needs to create/ edit an object, I create an object, stuff it/ get it stuffed with data, and/or create/ display the editor window. The user may have many such windows open at the same time, including multiple windows from the same class. When the user interacts with the windows and controls, the event handlers need to be able to find the right object. Microsoft's "sender" argument solves this need nicely. Microsoft's "eventargs" argument solves other needs nicely. Does Win32::GUI have equivalents? TIA, David ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ Perl-Win32-GUI-Users mailing list Per...@li... https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users http://perl-win32-gui.sourceforge.net/ |
Re: [perl-win32-gui-users] tutorials use strict? use warnings?
globals? sender and eventargs? $self?
From: <jez...@ho...> - 2008-02-22 10:25:54
|
> To do this have a look at the UserData method. It allows you to > associate data to a window. When you use NEM events the first parm is > the object that the event fired on. Say for example you have a button > on a form, and you have many instances of that form your even handler > would look like: > My $self=shift; #the button object > My $parent = $self->parent; #the parent window > My $object = $parent->UserData; #the instance data for the window I guessed at a solution like that, but didn't see $self in the documentation for Button_Click(): http://perl-win32-gui.sourceforge.net/cgi-bin/docs.cgi?doc=button Where is this documented? ________ It should be documented in the NEM section. Win32::GUI supports two event modles OEM (old event model) and NEM (new event model). OEM is like visual basic, with the control name and the event name. So if a button was called "hello" and the button was clicked, the sub hello_Click would be called. OEM is only sutible for simple scripts With NEM you pass the reference of the sub that you want to run in response to an event (this makes NEM faster). To some exent a NEM event is like a method being called on that control and as such, the first parm being passed is the control. Does that help? Again no win32::GUI on this box..... Cheers, jez ----------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ Perl-Win32-GUI-Users mailing list Per...@li... https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users http://perl-win32-gui.sourceforge.net/ _ |
Re: [perl-win32-gui-users] tutorials use strict? use warnings?
globals? sender and eventargs? $self?
From: David C. <dpc...@ho...> - 2008-02-23 06:10:03
|
jez_white wrote: > Win32::GUI supports two event modles OEM (old event model) and NEM > (new event model). OEM is like visual basic, with the control name > and the event name. So if a button was called "hello" and the button > was clicked, the sub hello_Click would be called. OEM is only sutible > for simple scripts But, apparently, does not provide VB-like sender and eventargs arguments to the event handler (?). > With NEM you pass the reference of the sub that you want to run in > response to an event (this makes NEM faster). > To some exent a NEM event is like a method being called on that > control and as such, the first parm being passed is the control. > It should be documented in the NEM section. > Does that help? Again no win32::GUI on this box..... Okay, thanks for the pointer. I was not aware of OEM and NEM: http://perl-win32-gui.sourceforge.net/cgi-bin/docs.cgi?doc=reference-opt ions Thank you, David |