From: Frazier, J. J. <Joe...@Pe...> - 2002-02-28 14:08:22
|
> -----Original Message----- > From: Aldo Calpini [mailto:dad...@al...] > Sent: Thursday, February 28, 2002 8:18 AM > To: Frazier, Joe Jr; Perl-Win32-GUI-Users > Subject: Re: [perl-win32-gui-users] Win32::GUI Release 0.0.665 >=20 >=20 > Frazier, Joe Jr wrote: > > > $Window->AddButton( > > > -text =3D> 'say hello', > > > -onClick =3D> sub { print "hello, world!\n"; }, > > > ); > > > > Hmmm... is this the ONLY way or does the old method still=20 > work also? >=20 > the old method still works. but the main problem now is the=20 > interaction > between the methods. in a few words: >=20 > don't expect to use them both for the same window! >=20 > if you define a $Window with NEM events, *all* of the=20 > controls inside it > should have NEM events only, eg. no Button_Click won't work=20 > if the parent of > the Button has NEM events. I would probably do something simular to the way XML::SAX::* works and = do this=20 package My::Package; my $gui =3D My::Package->new() ..... .... sub myhandler{ } package main; my $Window =3D Win32::GUI::Window->new( # .... =20 -events =3D> { Terminate =3D> $gui->myhandler(); Activate =3D> sub { print "here I am!\n"; }, }, -onMinimize =3D> sub { print "no please!\n"; }, ); =20 Now, the question is, how does it work to pass in stuff such as the = listview passing the row clicked? or do we have to handle all that = ourselves? If this is covered in the docs(are the docs more fleshed = out?), let me know and I will check there. >=20 > this is a little tricky, I know; in fact I proposed to add a=20 > pragma when > loading Win32::GUI, like this: >=20 > use Win32::GUI Event_Model =3D> 'byref'; > #### only NEM events in this script! >=20 > or >=20 > use Win32::GUI Event_Model =3D> 'byname'; > #### no NEM events in this script! >=20 > but I still don't know what to do when you just say use Win32::GUI ;-) >=20 <vote type=3D"my opinion">Use old style by default. This avoids users = having to change thier code until they are ready to totally update thier = code.</vote> > BTW, NEM events can also be specified inside a single -events=20 > option (or in > mixed style), as in: >=20 > my $Window =3D Win32::GUI::Window->new( > # .... > -events =3D> { > Terminate =3D> sub { -1 }, > Activate =3D> sub { print "here I am!\n"; }, > }, > -onMinimize =3D> sub { print "no please!\n"; }, > ); >=20 ooooooooooo! me like. =20 > you can (err, should be able to, not really tested ;-) change=20 > events with > the Change() method. to cancel an event, undef it: >=20 > $Window->Change( > -onMinimize =3D> undef, > ); >=20 >=20 Awesome! If this works, it will greatly help me with some dynamic fields = I would like to be able to add. ie. Have a DB which builds your app = controls for you. Not "easily" possible in the old model, but it seems = very easy with this new model (assuming the change event thing works). Sorry to be a pain, but i am so excited to check this out and have a few = questions on gotchas I have ran into in the past before migrating. Joe Frazier, Jr. Technical Support Engineer Peopleclick Service Support Tel: +1-800-841-2365 E-Mail: mailto:su...@pe... |