I know [[This.text]] but how can i get the richtext of a component ？
What do you mean by “get richtext”? Rich Text is not a property or value, but rather a collection of formatting or style properties, like font, size, color, bold/italic/underline/strikethrough, etc. Technically, I’d say it is more of a document format than any kind of thing you can “get.”
Axure lets you set certain text styles as part of its rich text option in a Set Text action. But, Axure does not support getting any of these style properties. Neither does it support directly changing any of these dynamically. So, you’ll need to “roll your own” somehow. You should be able to programmatically determine text style properties based on how you set it up in the editor–or, in a more advanced manner, determine any changes based on how you allowed those changes in your interaction code.
Thanks mbc66， I know script injection and know the coding.
I just want to find a way to make a function of highlight multiple words in pure Axure.
There is a repeater , a column called “Column0”,
first row data: a1a2a3a4a
second row data: aaabbbcccaaabbbcccaaabbbccc
… any contains “a”
“a” is red in each row.
Oh, I misunderstood. I thought you meant a literal “get” instead of actually setting rich text. This has got to be easier with RegEx, which Axure doesn’t support, but you should be able to do with js injection. Here is a thread for basically injecting regex support into Axure:
Doing this in pure Axure could be a pain, but seems like it could maybe work if you can set up a recursive loop to set the rich text char by char. Maybe don’t use Item Loaded to set the text but instead use a “listener event” like Move and use that to trigger a function to set rich text. My idea here is a recursive loop (like change dp state every 100 ms) that tests the first char only and if an ‘a’ it calls Set Text (rich text) setting that char to red, if not set that char to black; then (loop and) test the second, etc.
I tried this out and couldn’t get it to work. I don’t think there is a way in Axure to change the text value of a widget with “dynamic rich text” per string character. There would need to be a way to retain the current rich text styling of a widget and change only a portion, or substring. Setting rich text is “all or nothing” …so you can change one character or substring to a different color, but not multiple chars at random or dynamic positions. Iterative calls to Set Text (rich text) either delete previous/subsequent parts of the string, or recolor the whole string. …Maybe someone knows a solution though?
Here’s the closest I could get, a kind of brute force hack solution for your problem. The tradeoff is the string gets represented as one widget per char–with some preset or maximum string length, so it basically turns any font into a fixed-width font. If that is acceptable, this is a pretty straightforward solution. You could potentially resize the width of the widgets and move them, based on the px width of the proportional font char, in order to keep the proportional font layout.
dynamic rich text in repeater.rp (112.6 KB)
Page 1 shows the hack solution. Page 2 shows my tests and attempts to apply dynamic rich text formatting.
I think in the current version, it is difficult to implement this function without injecting script. Put it aside for now.
Thanks again, you are master!
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.