From: JHJL on
Hi all and Happy New Year

I am getting confused trying to programatically set the selection in a
text widget. I am implementing a search dialog which uses the text
widget search command to return the match indexes. This works. I then
add the "sel" tag to the matched range and this works too because if I
use tk_textCopy the correct text is copied to the clipboard.

The problem I have is that I cannot see the text that is tagged with
"sel". If I drag select with the mouse I do see the selection
highlighted but using tag add sel first last does not seem to give a
visible selection. If I create a tag to use as a highlighter (e.g .t
tag configure YELLOW -background YELLOW) and then do

.t tag add YELLOW sel.first sel.last

The correct text is highlighted


As ever a kick in the right direction will be gratefully recieved !

Thanks in advance
Julian
From: JHJL on
I think I have solved it, I needed to give the text widget focus
first...

Unless a guru can steer me on a better path :)

On Jan 13, 6:44 pm, JHJL <j...(a)hippospace.com> wrote:
> Hi all and Happy New Year
>
> I am getting confused trying to programatically set the selection in a
> text widget. I am implementing a search dialog which uses the text
> widget search command to return the match indexes. This works. I then
> add the "sel" tag to the matched range and this works too because if I
> use tk_textCopy the correct text is copied to the clipboard.
>
> The problem I have is that I cannot see the text that is tagged with
> "sel". If  I drag select with the mouse I do see the selection
> highlighted but using tag add sel  first last does not seem to give a
> visible selection. If I create a tag to use as a highlighter (e.g .t
> tag configure YELLOW -background YELLOW) and then do
>
>  .t tag add YELLOW sel.first sel.last
>
> The correct text is highlighted
>
> As ever a kick in the right direction will be gratefully recieved !
>
> Thanks in advance
> Julian

 | 
Pages: 1
Prev: Tktable tags
Next: tcllib transfer module