in reply to Re^2: Tk::Text selection testing
in thread Tk::Text selection testing

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;

Replies are listed 'Best First'.
Re^4: Tk::Text selection testing
by bass_warrior (Beadle) on Dec 06, 2004 at 18:12 UTC
    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.