I know Im going to regret replying with out testing my codeJ
The way I handle this kind of thing is to eval the handler for each object,
which in turn calls a generic handler, something like this:
foreach my $button ('one','two','three','four') {
my $string='sub ::'.$button.'_Click {
::Generic_ButtonClick('."'$button'".');}';
eval $string;
print "$string \n";
die 'error with eval '.$@ if $@;
}
sub ::Generic_ButtonClick {
my $button=shift;
print "$button clicked";
}
Hopefully that will make some sence,
cheers,
jez.
From: Gerard ter Haar <[EMAIL PROTECTED]>
To: perl-win32-gui-users@lists.sourceforge.net
Subject: [perl-win32-gui-users] How to define generic handler for buttons
Date: Fri, 16 May 2003 14:12:15 GMT
Hi,
I have just started with Win32::GUI. I want to create a small application
which starts a
main window with a lot of buttons on it. The buttons are read from a
config-file.
So far so good, the visual creation works just fine! However I now have a
lot of
dynamically created buttons and therefore can't add all
'<ButtonName>_Click' functions to
my application.
Can I define a general Button-handler? Based on the ButtonName I can
determine what to do.
Please advice, I haven't found anything is the FAQ/etc.
Thanks and kind regards,
gerard ter haar
-------------------------------------------------------
Enterprise Linux Forum Conference & Expo, June 4-6, 2003, Santa Clara
The only event dedicated to issues related to Linux enterprise solutions
www.enterpriselinuxforum.com
_______________________________________________
Perl-Win32-GUI-Users mailing list
Perl-Win32-GUI-Users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users
_________________________________________________________________
Get Hotmail on your mobile phone http://www.msn.co.uk/msnmobile