Hi Steve,
Steve Cookson wrote:
I'm comfortable now with how to identify which event called the
event-handler,
but I'm still struggling to understand how to identify the variables
involved when
$self is not passed as a parameter.
Previously you wrote:
OK I'm making some progress. The event passes $self and $event
to the subroutine.
So isn't self _always_ passed as a parameter to the subroutine? When is
it not passed? Which 'involved variables' are you trying to identify there?
But then I want to find out which control was clicked so I use
$self->GetId() and I get "-205". What is this?
That looks to me very much like the ID of the widget (or the 'window' as
the docs insist on referring to them) that was clicked. This seems
usually to be the second arg passed in creating the few components I've
used, 'parent' being the first.
Every widget ('window') in a program has a unique integer ID. Most of
the time it's never important to find it out and refer to widgets by
that ID, so the program can be left to assign a random ID itself. This
is done by passing -1 for the ID argument in wxPerl - in wxWidgets you
can use the identifier wxID_ANY, which I feel improves readability.
Anyhow, randomly / automatically assigned IDs are always negative and
user-designated ones must always be positive. So could you solve your
problem by giving 'proper' IDs to the widgets that need to call this
search function and distinguish between them that way? That'd depend on
$self always being available, as I was asking about above. For instance,
if you $Event->Skip() for both the TextCtrl and the Button in order to
have them use the \&OnClick or whatever event in their parent Frame, I
don't know if $self retains the value of the original widget that
received the event.
-- Ryan