| Store | Cart

Confusiong using focusOut binding

From: Martin {martlbub} Kraegeloh <m...@dm-server.cv.com>
Wed, 27 Sep 95 17:42:30 +0100
Hi, the following code behaves other than I expect:

when pressing tab in the upper entry, I want to get control, verify
the contents, and then move on. Instead, the focusOut routine gets
called twice. Why? 

Can some kind soul enlighten me, please?

Thanks in advance, Martin

------------------- 8< ----------- snip ... ---------------

use Tk;
use Tk::Dialog;

#---------- top level win --------------------------------------------------
$top = new MainWindow;
$top->title("problem");

#---------- menu buttons from structure? -----------------------------------

for($i=0;$i<3;$i++){
   # create entry 
   my $e = $top->Entry(-relief => 'sunken', -width => '20');
   $e->pack();
   # check if leaving field
   $e->bind('<FocusOut>', sub{&call_back_focus_out($e,$top)});
   # return emulates <tab>
   $e->bind('<Return>', 'focusNext');
}

MainLoop;

sub call_back_focus_out{
my $me=shift;
my $parent=shift;
# uncommenting will prevent two dialogs at a time, still the dialog appears
# twice ...
#return if $parent->{checking} && $parent->{checking} ne $me;
$parent->{checking}=$me;
$top->Dialog(
   -title => "test",
   -text => "test",
    -default_button => 'OK',
    -buttons => [ 'OK' ])->show();
$parent->{checking}='';
}

Recent Messages in this Thread
Martin {martlbub} Kraegeloh Sep 27, 1995 04:42 pm