Hi Steve,

Steve Cookson wrote:
The specific event I am interested in is tabbing out of a field to trigger validation (ie a table lookup), however, this uses wxEVT_KILL_FOCUS. wxEVT_KILL_FOCUS only passes the id of the control that was clicked and event. It is also triggered when you do alt-tab (in Windows) to
Skip to another application, which I'm not interested in.  So I've come up
With the following strategy:

1) Use
use vars qw($gl_self_ptr);      # Declare global $self pointer
.
.
.

$gl_self_ptr = \$self;          #Set global $self pointer.

To se a global variable pointer to $self in the main OnInit routine.

2) Use wxEVT_KILL_FOCUS to pick up the "lose focus" event.

        my ($self, $event) = @_;
        if ($event->GetEventType() eq wxEVT_KILL_FOCUS){         #$Self
is the control on the form.
            if ($self->GetValue() eq ""){return};               #Ignore if
nothing in field
            $self=$$gl_self_ptr;                                #set Local
Self to global self.
        };

And ignore it if there is nothing in the field (eg alt tab or just an empty
field).

Otherwise set $self to the pointer to the main screen so that I can
Do cross validation etc.

What do you think?

But I haven't tried $Event->Skip(), so that might help too.
I'm afraid I'm so new to wxPerl that giving any more of an informed opinion than what I've already said would involve an amount of experimentation that I can't indulge in right now, so I've posted this back on-list in the hope that someone else can comment on your technique.

It strikes me that you're not really asking for anything terribly complicated: you just want two different events to call the same function. So my suspicion would be that there's a simpler way to do it.

Can both the TextCtrl's OnLoseFocus and the Button's OnClick event both call a Form-level function called ValidateText() or whatever, which would access the text through the GetValue() method of $name_of_TextCtrl? You could do your check to make sure that the whole Frame hasn't lost focus in there.

If that's not possible you could search the archives of the main wx-users mailing list [0] for a similar question (you might want to search from a proper search engine though, I find the search inside Google Groups to be freaking dire).

Like I said, it sounds like it's a simple thing you want. Sorry I'm not able to give a Right Answer!

-- Ryan


[0] http://groups.google.com/group/wx-users/topics

Reply via email to