Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

Re: pTk Text Selection: Win32 Issue?

by thundergnat (Deacon)
on Dec 04, 2012 at 17:27 UTC ( #1007126=note: print w/ replies, xml ) Need Help??

in reply to pTk Text Selection: Win32 Issue?

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:

use strict; use warnings; use Tk; my $mw = new MainWindow; my $lines = "Distribution ILYAZ/os2/tk/ Distribution INGY/Kwiki-Zipcode-0.12.tar.gz Distribution ISHIGAKI/Archive-Any-Plugin-Bzip2-0.01.tar.gz Distribution JAE/perlipse/ Distribution JALYCAI/ Distribution JAME/ Distribution JBNIVOIT/ Distribution JBRYAN/ Distribution JBRYAN/ Distribution JBRYAN/ Distribution KRYDE/Filter-gunzip-4.tar.gz"; my $entry = $mw->Entry->pack; my $txt = $mw->Text(-selectbackground=>'lightgreen')->pack; my $but = $mw->Button(-text=>'List Selected to STDOUT', -command=>sub{ print STDERR $txt->getSelected,"\n"; print STDERR "HI THERE\n"; })->pack; $txt->insert('end', $lines); $txt->tagConfigure('winsel', -background => $txt->tagCget('sel','-back +ground')); $txt->bind('<<Selection>>', sub { $txt->tagRemove('winsel','1.0', 'end'); return if !defined $txt->tagRanges('sel'); $txt->tagAdd('winsel', $txt->tagRanges('sel')) } ); MainLoop;

Create your own tag with the same coloring then shadow the selection tag. Works on windows and shouldn't cause problems elsewhere.

Comment on Re: pTk Text Selection: Win32 Issue?
Download Code

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1007126]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (9)
As of 2015-11-25 07:44 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (672 votes), past polls