General XMetaL Discussion

XMetaL Community Forum General XMetaL Discussion Setting a document as read-only

  • LeeHart

    Setting a document as read-only

    Participants 1
    Replies 2
    Last Activity 13 years, 8 months ago

    I must be missing something. I see references to marking nodes as read-only, but I don't see that having any effect.

    I'd like for a document that is read/only in the filesystem to not be editable; I'd prefer if any attempt to change the content would just cause a beep. I don't see how to do this. The Selection and Range objects have a promising WritePermittedContainer property, but even when I set the property to False the text can still be changed. Here's the code I was using to try to set it on the entire document:

    // XMetaL Script Language JSCRIPT:
    // Find Title element and display its text
    var rng = ActiveDocument.Range;
    rng.SelectAll();
    rng.WritePermittedContainer = false;
    ActiveDocument.Host.Alert(rng.WritePermittedContainer);

    I tried setting it on just the current selection using the code below, but even though it displays False for the WritePermittedProperty I can still change the contents.

    // XMetaL Script Language JSCRIPT:
    Selection.WritePermittedContainer = false;
    ActiveDocument.Host.Alert(Selection.WritePermittedContainer);

    My primary interest is XMetaL 5.5, but if there's a way to do this for XMetaL 4.0 as well it would be helpful.

    References to Read The Fine Manual would be appreciated if they include a pointer where to look.

    Thanks,

    Lee

    Reply

    mag3737

    Reply to: Setting a document as read-only

    Look at ReadOnlyContainer, another read/writeable property on Selection/Range objects.  Setting it to true will make everything in that selection's container read-only.

    Setting the WritePermittedContainer flag to true allows you to create “islands of writeable” inside read-only containers.  In some quick testing just now, it looks like this can even be done *before* setting the read-only property on the outer container.

    Both of these properties get reset throughout the document if you leave Normal/TagsOn view.

    As for the beep, I'm not sure how to do that.  Default behaviour is that XMetaL will display an alert when the user tries to type in a read-only area.

    Reply

    LeeHart

    Reply to: Setting a document as read-only

    Thank you – that's just what I was looking for.

    I wish the docs were better cross-linked, e.g. between WritePermittedContainer and ReadOnlyContainer.

    Lee

    Reply

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

Lost Your Password?

Products
Downloads
Support