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
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.