[perl] Derived classes and events
Johan Vromans <[email protected]>
| Newsgroups | gmane.comp.python.wxglade |
|---|---|
| Organization | Squirrel Consultancy |
| Message-ID | <[email protected]> |
Some time ago (november 2008, to be precise, see [1]) we've discussed the
following:
+------
| One of the ways to work with wxGlade generated [perl] classes is to
| have wxGlade generate base classes, and then to derive your own
| classes from the base classes. This way there's no need to modify the
| wxGlade generated classes (using #begin/end wxGlade).
|
| However, that doesn't seem to work for events. Events are not method
| calls, but subroutine calls. It is not possible to override them in
| the derived class. It is possible to redefine them, but that is ugly.
+------
The final solution was to change the generated code from
Wx::Event::EVT_BUTTON($self, $self->{button_1}->GetId, \&buttonpush);
to
Wx::Event::EVT_BUTTON($self, $self->{button_1}->GetId,
$self->can('buttonpush'));
For non-perlers: \&buttonpush is a hard reference to the local subroutine
buttonpush, while $self->can('buttonpush') performs a dynamic lookup of the
routine which takes inheritance into account.
However, for some reason this change never got applied.
So I would like to revive this proposal.
-- Johan
https://sourceforge.net/p/wxglade/mailman/message/20840497/
------------------------------------------------------------------------------
Find and fix application performance issues faster with Applications Manager
Applications Manager provides deep performance insights into multiple tiers of
your business applications. It resolves application problems quickly and
reduces your MTTR. Get your free trial!
https://ad.doubleclick.net/ddm/clk/302982198;130105516;z