Gabor Szabo wrote:
I have a menu item created like this:

my $file_save = $menu->Append( Wx::wxID_SAVE, "&Save" );
Wx::Event::EVT_MENU( $win,
                $file_save,
                \&on_save,
);


I try to emulate clicking on this menu item:

my $event = Wx::CommandEvent->new( Wx::wxID_SAVE, -1 );
$main->ProcessEvent($event);

but it does not reach he on_save event handler.

  I hope you don't still need this... anyway, for the archives:
in general, it is a bad idea to construct an event and
send it to wxWidgets like you do, because most native
events do some bookkeeping _before_ sinthesizing and
sending a wx-level event.

  For a menu click you can probably get away with it,
just cahnge te constructor call to:

  Wx::CommandEvent->new( wxEVT_COMMAND_MENU_SELECTED, wxID_SAVE );

(or something like that, I am not sure wxEVT_COMMAND_MENU_SELECTED is
the correct event type).

Regards,
Mattia

Reply via email to