On Sun, 25 Nov 2007 14:44:00 +0200
"Octavian Rasnita" <[EMAIL PROTECTED]> wrote:

> From: "Mattia Barbon" <[EMAIL PROTECTED]>
> > On Tue, 20 Nov 2007 19:01:45 +0200
> > "Octavian Rasnita" <[EMAIL PROTECTED]> wrote:
> >
> >> Is it possible to use just default control IDs (-1) in a WxPerl 
> >> application?
> >>
> >> With other words, if we find the controlID using $event->GetId() in an 
> >> event
> >> handler, can we access the control's properties and methods?
> >
> >  There also is $event->GetEventObject.
> 
> Ok, thank you. It seems that there is another thing I don't know...
> 
> I have tried in the event handler subroutine:
> 
> my $label = $event->GetEventObject->GetLabel;
> 
> ...but it works only for some controls, like the button, however it doesn't 
> work for the menus.
> 
> How can I find the label of a menu item from a $event object if I don't know 
> the ID of that menu item?

  In this case you can always use $event->GetId to get at the control/menu item 
ID.
Sorry, I did not mean to imply your original suggestion was bad, I just wanted 
to
suggest an alternative.

> Or better said, how can I find the label of the control that fired the 
> event, no matter what type of control is?

  I do not think this is possible.

> I might fire an event with a menu item, with a toolbar button, and with a 
> common button, and from $event I want to know which of the controls fired 
> it. Is it possible?

  I do not think you can do that using just what wxWidgets provides.
You can of course use something like:

  EVT_BUTTON( ... sub { $self->do_it( 'button' , $_[1] ) } );
  EVT_MENU  ( ... sub { $self->do_it( 'menu'   , $_[1] ) } );
  EVT_TOOL  ( ... sub { $self->do_it( 'toolbar', $_[1] ) } );

but you likely have already figured that out yourself...

Regards,
Mattia

Reply via email to