General XMetaL Discussion

XMetaL Community Forum General XMetaL Discussion API call to pause UI updates

  • paul_cpwr

    API call to pause UI updates

    Participants 2
    Replies 3
    Last Activity 10 years, 6 months ago

    I seem to remember an API call that would enable/disable UI display updates. I think I was using it while doing a bunch of selection manipulation and I didn't want the user to see the cursor dancing all over the window.

    I can't find this in the XMetaL Developer 6.0.1.023 API doc. Does it still exist?

    Thank you for your help.

    Best regards,

    Paul Anderson
    Compuware Corporation

    Reply

    tonys

    Reply to: API call to pause UI updates

    I think you mean the FormattingUpdating property of the Document object.

    Tony S.

    Reply

    mag3737

    Reply to: API call to pause UI updates

    It does sound like this is referring to FormattingUpdating. Its main purpose is to improve performance a bit by temporarily disabling the display formatter while you are doing some intensive mucking around with your document.

    As to the “dancing cursor”, another possibly relevant item is the use of Range instead of Selection. Range has exactly the same object model as Selection, but a Range object is “invisible” (and you can have multiple different ones in a script). Selection (particularly ActiveDocument.Selection) literally refers to the visible cursor/highlight in the document.

    Reply

    paul_cpwr

    Reply to: API call to pause UI updates

    Tony and Tom are both correct; FormattingUpdating was the property I was trying to remember.

    As for Range vs Selection, I tend use Range whenever possible. In this case, I am inserting a sequence of elements (and elements within elements) and I wasn't sure I could do that with a range. In short, start with an empty range, add a tree of new elements to it, and then manifest it within the document.

    This is a DITA use case. The user is inserting a strow or an sthead into a simpletable. The goal is to insert a strow or sthead that contains a number of stentry children (with child p element, as required by our DITA constraints) that is equal to the number of stentry elements in the first row-like element in the simpletable. The cursor should end up in the first p in the first stentry of the inserted strow or sthead.

    The following is the element insertion logic that comes after I've analyzed the simpletable element and counted the stentry elements in the first strow or sthead. The elem variable is the name of the stentry or sthead being inserted. The entries variable is the number of entries found earlier.

        var firstp; //first p in first stentry; destination of cursor when done.
        var currentEntry; //current stentry being populated
        Selection.InsertElement(elem);
        for (i = 1; i <= entries; i++) {
            Selection.InsertElement(“stentry”);
            currentEntry = Selection.ContainerNode;
            Selection.InsertElement(“p”);
            //Header cells get insertion text.
            if (elem == “sthead”) {
                Selection.InsertReplaceableText(“Enter new header”);
            }
            if (i == 1) {
                firstp = Selection.ContainerNode;
            }
            Selection.SelectAfterNode(currentEntry);
        }
        Selection.SelectNodeContents(firstp);
        Selection.Collapse(sqCollapseStart);

    These insertions is where the cursor moves around a bit. I can either wrap that logic in calls to Document.FormattingUpdating or if there's a more efficient alternative, let me know.

    Best regards,

    Paul Anderson
    Compuware Corporation

    Reply

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

Lost Your Password?

Products
Downloads
Support