my $mockOb = SomeClass->new;
my $search = $contentFrame->new_ttk__entry(-takefocus => 1, -font => '
+Arial 11', -width => 40, -validate => 'focusout', -textvariable =>\$
+mockOb->search, -validatecommand => [\&searchValidation, Tkx::Ev('%P
+')]
);
# Write information back to our $mockOb
$search->bind('<FocusOut>', sub { $mockOb->search( $search->value )});
sub searchValidation{
....do crazy stuff
}
SomeClass
sub new {
my $class = shift;
my $self = {
search = ""
};
bless $self, $class;
return $self;
}
sub search{
my $self = shift();
if(@_) {
$self->{search} = shift();
}
return $self->{search};
}
But I haven't done Tk for a long time, so I don't know how applicable my idea of handling the focus event is, and if it is actually done the way that I wrote above untested code. |