in reply to Tk::Text selection testing

Tk::Error: text doesn't contain any characters tagged with "sel"

Read the section for Selection in perldoc Tk::Text. You need to set "exportSelection =>1"


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

Replies are listed 'Best First'.
Re^2: Tk::Text selection testing
by bass_warrior (Beadle) on Dec 06, 2004 at 16:20 UTC
    I have exportselection set, how to I test to see if something is selected though?
    if ($txtbox->sel) { }
      The following works for me:
      use Tk; use strict; my $mw = MainWindow->new; $mw->title("Hello World"); my $txt = $mw->Text(-exportselection => 1); $txt->pack; $mw->Button(-text => "Done", -command => sub { if ($txt->getSelected) { print $txt->getSelected,"\n"; } else { print "No text selected\n"; } exit })->pack; MainLoop;
        Thanks, I was trying to use:
        $txt->get('sel.first', 'sel.last');


        and if nothing was selected Tk::Text was spitting out errors about sel.first not being defined.
        Using getSelected fixed that.