in reply to Using Ctrl A and del in the Entry widget in perl tk

#!/usr/bin/perl use warnings; use strict; use Tk; my $mw = new MainWindow; my $ent = $mw -> Entry() -> pack(); $ent->focus; $ent->bind('<Control-a>', \&clear ); $ent->bind('<Delete>', \&clear ); MainLoop; sub clear { $ent->delete(0,'end'); }

I'm not really a human, but I play one on earth.
Old Perl Programmer Haiku ................... flash japh

Replies are listed 'Best First'.
Re^2: Using Ctrl A and del in the Entry widget in perl tk
by choroba (Cardinal) on Oct 21, 2011 at 11:33 UTC
    I think the OP meant "Use Ctrl+A to select the entire entry, and then Del to delete it". Or maybe not?
      Thats easy enough to accomplish, since after a selection, a Delete press will delete the selection.
      #!/usr/bin/perl use warnings; use strict; use Tk; my $mw = new MainWindow; my $ent = $mw -> Entry( -bg => 'white', -selectbackground => 'hotpink', ) -> pack(); $ent->focus; $ent->bind('<Control-a>', \&select_it ); MainLoop; sub select_it{ $ent->selectionRange(0,'end'); }

      I'm not really a human, but I play one on earth.
      Old Perl Programmer Haiku ................... flash japh