[ Apologies if this was received before; I think I had a problem after changing my subscription address, and it wasn't showing up on nntp.perl.org~ ]

Hi James,

GMAIL - James McDonald wrote:
I am not really understanding the event subsystem very well. Of course I have looked at the documentation but due to my lack of understanding I still am not grasping the concept. I have little idea of what $event->Skip means and where in the block it should appear, if at all. Can anyone enlighten me?
My understanding from the C++ is that $event->Skip indicates that the handling of an event should be passed on higher up the inheritance chain, first of the object itself, then its parent object, etc. So for example (from the wxWidgets book), in a myTextCtrl subclass, you could handle its keypress events to filter out certain keys by returning without calling $event->Skip or $event->Skip(0) to be explicit, then for all other keys do $event-Skip and the event will be handed on to be handled normally by the regular TextCtrl class. For events handled in a myFrame class, Skip'ed events would get passed on to the regular Wx::Frame, then Wx::TopLevelWindow, then Wx::Window.

So in your code:
sub keyPress {
   my ($self, $event) = @_;
# wxGlade: MyFrame::keyPress <event_handler>

   warn "Event handler (keyPress) not implemented";
   $event->Skip;
   my $key = $event->GetEventObject()->GetLabel();
   my $keyid = $event->GetEventObject()->GetId();
# end wxGlade

   Wx::MessageBox("You pressed: $key\nKey ID: $keyid", "wxPerl Sample");

}
I think it just means these wxEVT_BUTTON events will be passed on to Wx::Frame when your MyFrame sub has finished with them.
But let's say I want to know the actual control name such as return "button_1" from the EVT_BUTTON event how do I return that? I can use GetId to return the default number but how do I return it's programmatic name?
$self->{grid_sizer_1}->Add($self->{button_1}, 0, 0, 0);
I'm afraid I don't know how to do exactly what you want, without resorting to something silly with naming conventions and eval()s. As Steve already said though, I think id's are the way to go. It's probably easiest to use usefully-named integer scalars so your check will look something like if ( $event->GetEventObject->GetId == $ID_KEY9 ). You can see this idea used in wxToolBar.pm in Wx::Demo.

HTH,

-- Ryan

Reply via email to