Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Changing Style on Tk::Text

by batkins (Chaplain)
on Aug 20, 2003 at 19:13 UTC ( [id://285264]=perlquestion: print w/replies, xml ) Need Help??

batkins has asked for the wisdom of the Perl Monks concerning the following question:

I'm currently writing a widget that will allow the user to click a button and change the style of all future text typed by the user. Essentially, the user clicks a button for the appropriate style and then a tag should be applied to all further text typed into that Text widget.

I tried $self->{text}->tagAdd('name of tag', 'insert') but this didn't work. What I ultimately had to do was create a second tag called 'elide' that had the elide attribute set to l and do this:

$self->{text}->insert('insert', '%%IGNORETHIS%%', ['elide', 'name of tag'])

So what this did was insert an invisible string at the end of the text which had the appropriate style. When I compine both of these methods together (that is, I add the tag to insert and then print out the dummy text), all characters typed after the style change are displayed with the proper tag.

This doesn't seem very neat to me, though. Is there some better way to do this?

Bill

edited by ybiC: balanced <code> tags

Replies are listed 'Best First'.
Re: Changing Style on Tk::Text
by bobn (Chaplain) on Aug 20, 2003 at 23:21 UTC

    It would be much easier ofr others to help if you included some more of your code.

    Also, I'm guessing you used the construct [ 'elide', 'name of tag' ], which when used here, turns into a link to: "http://perlmonks.com/index.pl?node='elide', 'name of tag'" - if that's not what you want you should wrap your code fragments in <code> </code> tags.

    --Bob Niederman, http://bob-n.com

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://285264]
Approved by tcf22
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (5)
As of 2024-04-25 11:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found