Alessandro wrote:

# define context menu
$this->{ResSecCtx}     = Wx::Menu->new();
$this->{NewResSec}     = $self->{ResSecCtx}->Append( 71000, "New Reserved
Section...", "" );
$this->{ModResSec}     = $self->{ResSecCtx}->Append( 72000, "Modify Reserved
Section...", "" );
...
# bind events
Wx::Event::EVT_MENU( $self, $self->{NewResSec}, \&OnNewReserved);
Wx::Event::EVT_MENU( $self, $self->{ModResSec}, \&OnModReserved);

You need to supply the ID of the menu item, not the item itself:

Wx::Event::EVT_MENU( $self, 71000, \&OnNewReserved);
Wx::Event::EVT_MENU( $self, 72000, \&OnModReserved);

<snip>

The context menu is correctly displayed but it seems that no event is sent
when I select a choice because event handlers are not executed.
Could you help me to understand the problem?

Thank you
Alessandro


As a sidenote (and a personal preference), I found that using a combination of constants and Wx::NewId() helps the readability of the code and avoids id clutter, especially when your projects get bigger.

Eg:
use constant ID_MENU_EXIT => Wx::NewId();
use constant ID_TRANSFER_QUEUE => Wx::NewId();
....
Wx::Event::EVT_MENU( $self, ID_MENU_EXIT, \&OnExit);
Wx::Event::EVT_MENU( $self, ID_TRANSFER_QUEUE, \&OnTransferQueue);

...again, this is personal preference  :)

Hope it helps,

Cheers,
Huub Peters

Reply via email to