Thanks for that, Mattia, prototype() working nicely.
On Mon, Sep 22, 2008 at 6:03 AM, Mattia Barbon <[EMAIL PROTECTED]>wrote:
> Ian Macdonald wrote:
>
> 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?)
>>
>
> At the moment the only way is using the length returned by
> prototype().
>
> 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.
>>
>
> The definition is the same; just some are defined using Perl code,
> some using C++ code; from the Perl side they should appear exactly the
> same, regardless of where they are defined.
>
> Is this:
>> a) a quirk of wxPerl?
>> b) a quirk of wxWidgets?
>> c) totally wrong and I've missed something easy?
>>
>
> d) an implementation detail that should not impact
> user code in any way
>
> HTH
> Mattia
>
--
Ian Macdonald