If you have the last Win32::GUI 0.0.655, you can use the NEM (New Event
Model) for set an event function at creation time.

$Button = $Window->AddButton  (
    -name     => "Test",
    -text     => "Test",
    -events   => { Click => \&Test },
    # -events   => { Click => "Test" },
    # -events   => { Click => sub {print " Test click !!!\n"; } },
);

# Test routine
sub Test {
  my $self = shift;
  my $name = $self->{-name};
  print "$name click !!!\n";
}

Laurent


> 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.

<<attachment: nembutton.zip>>

Reply via email to