tcl >> text widget: how to get highlighted stuff

by Saab Siddiqui » Fri, 29 Aug 2003 06:07:58 GMT

nevermind.. ignore me... i should do more reading....

the answer is as follows:

# to get selected text
% .t1 get sel.first sel.last
rfewrfer

# to get the line.char position of the selected text
% .t1 index sel.first
1.3


"Saab Siddiqui" < XXXX@XXXXX.COM > wrote in message
news:bilt3l$1ji$ XXXX@XXXXX.COM ...
> hey y'all...
>
> i am going nuts with this... just cannot seem to figure it out... arrghh!
>
> how the heck do you get highlighted text from a text widget...
>
> basically, i want to get the highlighted text and allow the user to
"strike
> it out".... via the tag strikeout thingie...
>
> thanks,
> saab
>
>




tcl >> text widget: how to get highlighted stuff

by Bryan Oakley » Fri, 29 Aug 2003 06:11:10 GMT






What you want is the "selection", which has it's own section in the text
man page (under the heading "the Selection". You'll also need to read a
little under the Tags section to see how you can qualify tags with
things like ".first" and ".last" amoung others.

Using that information, the answer to your question is this:

set text [.text get sel.first sel.last]

For your purposes you don't need to actually get the text, you just need
to apply your strikethrough tag to the same range as the sel tag:

.text tag add strikethrough sel.first sel.last




Similar Threads

1. How to highlight all the Text for a Text field when getting focu

2. highlight text in text widget

3. How to highlight in a text widget

I'm having diffuculty finding out how to select/highlight a word in a text 
widget.

How is this done?

Thanks,
Phil 


4. Highlight but no entry in text widget

5. keyword highlight in text widget

I am trying to make my text widget highlighting certain keywords. I
search the newsgroup archive and did not find anything easy.

Is there a simple way to do this ?


Regards
S-Y. Chen

6. Printing stuff - from a text widget

7. Highlight text and Text Box Control

C5.0b PE legacy

Hello!

I have one invoice application with the text area for variable
customer announcement.  It is now filled and printed using
the standard Arial characters.

Is there any easy and cheap method to highlight these 
messages?    (Compare "Word text")

TIA
Riku Maki



8. Getting text widget contents