> Hi,
>
> I'm looking for a way to invoke a command manually. I mean to do this:
>
> # Define the eventhandler for the button
> EVT_BUTTON($this, $this->{button0}, sub {print "gelukt!\n"});
> # Invoke it when someone clicks anywhere in the panel. This obviously
> # does not work:
> EVT_LEFT_DOWN ($this->{TOPPANEL}, sub {$this->{button0}->Invoke});
>
> I'm looking for a way to make this "Invoke" method work.
Do you mean that calling Invoke will cause a wxMouseEvent to be sent
to the button?
> I've looked into ProcessEvent, but that wants an event as parameter, and
> I can't find a way to create a "Click Button Event" object.
I din't do that mainly because this is not very useful, in general:
most of the time you can do:
sub Clicked {
my( $x, $y ) = @_;
}
sub OnClick {
# ...
Clicked( $x, $y );
}
sub OnLeftDown {
# ...
Clicked( $x, $y );
}
And generally, unless you are creating a custom control with custom
events ( think wxCalendarControl ), you don't want to directly send
events to controls, because a control receiving a system event will
do:
* some system dependent processing
* send the wxWindows' event
while sending an event directly to the control will miss
the system dependent processing; BTW, in the wxWindows' lists
generally you are discouraged to directly send system events to
controls ( user-defined events are OK ).
Before you ask: user-defined events are not yet implemented in
wxPerl.
Another reason you can't currently create a wxMouseEvent ( or
any other event ), is that, at the time, I _thought_ it broke
( or perhaps "would have broke"? but you get the idea )
memory management; I need to review that, perhaps.
Regards
Mattia
|