No such thing as a small change | |
PerlMonks |
Changing Style on Tk::Textby 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? Billedited by ybiC: balanced <code> tags
Back to
Seekers of Perl Wisdom
|
|