home *** CD-ROM | disk | FTP | other *** search
/ CD Actual Thematic 7: Programming / CDAT7.iso / Share / Editores / Perl5 / perl / lib / site / auto / Tk / Entry / Insert.al < prev    next >
Encoding:
Text File  |  1997-08-10  |  790 b   |  30 lines

  1. # NOTE: Derived from ..\blib\lib\Tk\Entry.pm.  Changes made here will be lost.
  2. package Tk::Entry;
  3.  
  4. # Insert --
  5. # Insert a string into an entry at the point of the insertion cursor.
  6. # If there is a selection in the entry, and it covers the point of the
  7. # insertion cursor, then delete the selection before inserting.
  8. #
  9. # Arguments:
  10. # w - The entry window in which to insert the string
  11. # s - The string to insert (usually just a single character)
  12. sub Insert
  13. {
  14.  my $w = shift;
  15.  my $s = shift;
  16.  return unless (defined $s && $s ne "");
  17.  eval
  18.   {local $SIG{__DIE__};
  19.    $insert = $w->index("insert");
  20.    if ($w->index("sel.first") <= $insert && $w->index("sel.last") >= $insert)
  21.     {
  22.      $w->deleteSelected
  23.     }
  24.   };
  25.  $w->insert("insert",$s);
  26.  $w->SeeInsert
  27. }
  28.  
  29. 1;
  30.