General XMetaL Discussion
karia April 10, 2015 at 1:26 pm
How to use HighlightRange to un-highlightApril 10, 2015 at 1:26 pmParticipants 3Replies 4Last Activity 7 years, 5 months ago
In my customization I use ActiveDocument.HighlightRange to highlight some portions of text. It works fine.
Now I want to un-highlight this text. I use following in XMetaL 9:
[code]var highlightRange = rng.selectionLocation.split(“;”) + “;” + startPos + “;” + endPos + “;”;
ActiveDocument.HighlightRange(highlightRange, 0, 0);[/code]
It does not work…
Programmer´s Guide describes the parametes
(string location, [long highlightType=0], [long highlightState=1], [string hint=””])
highlightState – 1 = highlight, 0 = un-highlight
What am I doing wrong?Derek Read April 16, 2015 at 12:02 am
Reply to: How to use HighlightRange to un-highlightApril 16, 2015 at 12:02 am
These APIs were incorrectly documented at some point before the APIs themselves were completed so that's probably what is confusing you. They were added for a specific partner's use and the only people that were given a demo that included them is that one partner (or perhaps 2) as far as I know.
I'm not sure if it makes sense to post that demo here on the forum, but I'll see if I can locate it. The one I know of was partially a proof of concept and written for version 7. Because the APIs were not supposed to really be public they may have been tweaked a bit since then. I'd want to see if what we did for that early demo makes sense with their current state before posting it.Derek Read April 17, 2015 at 7:46 pm
Reply to: How to use HighlightRange to un-highlightApril 17, 2015 at 7:46 pm
You can try the demo macros I'm attaching. To test them copy both files into the Startup folder in your XMetaL Author installation then restart.
The macros should all be near the top of the list in the Macros toolbar and dialog and each one is named to describe what it does.
I've tested the main macros and they all seem OK with version 9. However, the code that tries to persist the highlighting across sessions (by writing out that information) may not work right. I think it might rely on some additional scripts not included here.karia April 20, 2015 at 10:03 am
Reply to: How to use HighlightRange to un-highlightApril 20, 2015 at 10:03 am
Thanks a lot!
Saving the ids of the highlighted region and un-highlighting works using this:
var highlightId = ActiveDocument.HighlightRange(location, 12, 1);
Just one small problem: In the end of the document small part is highlighted (Screenshot attached is made with your sample customization) This occures on changing the view. Is it possible to omit this?
- You must be logged in to reply to this topic.