General XMetaL Discussion

XMetaL Community Forum General XMetaL Discussion How to use HighlightRange to un-highlight

  • karia

    How to use HighlightRange to un-highlight

    Participants 3
    Replies 4
    Last 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(“;”)[0] + “;” + 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?

    Reply

    Derek Read

    Reply to: How to use HighlightRange to un-highlight

    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.

    Reply

    Derek Read

    Reply to: How to use HighlightRange to un-highlight

    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.

    Reply

    karia

    Reply to: How to use HighlightRange to un-highlight

    Thanks a lot!
    Saving the ids of the highlighted region and un-highlighting works using this:

    [code]
    var highlightId = ActiveDocument.HighlightRange(location, 12, 1);
    […]
    ActiveDocument.SetHighlightedRangeState(highlightId, 2);
    [/code]

    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?

    Reply

    Derek Read

    Reply to: How to use HighlightRange to un-highlight

    The scripts aren't explicitly doing that (as far as I can see) so it looks like a bug.

    Reply

  • You must be logged in to reply to this topic.

Lost Your Password?

Products
Downloads
Support