Hi, I'm working on a application framework using wxPerl and I need to assign event handlers dynamically, eg the name of the event is supplied as a string and I do something like this to set up a generic handler:
{ no strict 'refs'; my $event_type = "Wx::Event::$event"; &{ $event_type}($parent, $control, sub { do_screen_event($rule, @_) }); } Which works fine, and since I'll be validating $event before here, the 'no strict refs' doesn't bother me too much. This example assumes the event is one where the parent argument is required; I know that this is not always the case. (Is there an easy way of going from event name to num args, eg EVT_PAINT => 2, EVT_TEXT => 3?) The only quirk appears to be for the events which directly track mouse button events; these are the only events not defined as wrappers for Connect() in Wx::Event.pm. It seems as if these are exceptions in that they are defined explicitly in the WXW library and so don't need wrappers in Wx::Event. Is this: a) a quirk of wxPerl? b) a quirk of wxWidgets? c) totally wrong and I've missed something easy? I have working code for both mouse events and "normal" events, I just want to check that I'm not digging myself a hole. Thanks, -- Ian Macdonald