<?xml version="1.0" encoding="windows-1252"?>
<node id="1007126" title="Re: pTk Text Selection: Win32 Issue?" created="2012-12-04 12:27:44" updated="2012-12-04 12:27:44">
<type id="11">
note</type>
<author id="449608">
thundergnat</author>
<data>
<field name="doctext">
&lt;p&gt;I believe, (though am not able to prove), that you are running into an issue with the way Windows handles selections. I haven't figured out a way to prevent that, though you can kind of half-assed work around it by doing something like this:&lt;/p&gt;

&lt;c&gt;
use strict;
use warnings;

use Tk;

my $mw = new MainWindow;
my $lines = "Distribution    ILYAZ/os2/tk/Tk-OS2src-1.04.zip
Distribution    INGY/Kwiki-Zipcode-0.12.tar.gz
Distribution    ISHIGAKI/Archive-Any-Plugin-Bzip2-0.01.tar.gz
Distribution    JAE/perlipse/Perlipse-0.02.zip
Distribution    JALYCAI/article_fetcher.zip
Distribution    JAME/ftndb-0.35.zip
Distribution    JBNIVOIT/Win32-ShellExt-0.1.zip
Distribution    JBRYAN/AI-NeuralNet-BackProp-0.77.zip
Distribution    JBRYAN/AI-NeuralNet-BackProp-0.89.zip
Distribution    JBRYAN/AI-NeuralNet-Mesh-0.44.zip
Distribution    KRYDE/Filter-gunzip-4.tar.gz";

my $entry = $mw-&gt;Entry-&gt;pack;
my $txt = $mw-&gt;Text(-selectbackground=&gt;'lightgreen')-&gt;pack;
my $but = $mw-&gt;Button(-text=&gt;'List Selected to STDOUT', -command=&gt;sub{
    print STDERR $txt-&gt;getSelected,"\n";
    print STDERR "HI THERE\n";
})-&gt;pack;
$txt-&gt;insert('end', $lines);

$txt-&gt;tagConfigure('winsel', -background =&gt; $txt-&gt;tagCget('sel','-background'));

$txt-&gt;bind('&lt;&lt;Selection&gt;&gt;', 
    sub {
        $txt-&gt;tagRemove('winsel','1.0', 'end');
        return if !defined $txt-&gt;tagRanges('sel');
        $txt-&gt;tagAdd('winsel', $txt-&gt;tagRanges('sel'))
    }
);

MainLoop;
&lt;/c&gt;

&lt;p&gt;Create your own tag with the same coloring then shadow the selection tag. Works on windows and shouldn't cause problems elsewhere.&lt;/p&gt; </field>
<field name="root_node">
1007107</field>
<field name="parent_node">
1007107</field>
</data>
</node>
