General XMetaL Discussion
XMetaL Community Forum › General XMetaL Discussion › Element no longer read-only after undo
-
lefrac01 February 4, 2021 at 7:42 am
Element no longer read-only after undo
February 4, 2021 at 7:42 amParticipants 4Replies 4Last Activity 1 year, 3 months agoGiven a read-only element, after the following code is run on it and the user presses undo, the element is not set back to read-only. I want to allow the user to delete an element with a button and be able to undo this action without losing the read-only protection.
ActiveDocument.BeginMutations(“example”)
rng.Select()
rng.ReadOnlyContainer = False
rng.NonRemovableContainer = False
rng.SelectElement()
rng.Select()
ActiveDocument.DeleteSelection()
ActiveDocument.EndMutations(True)nhu1 February 4, 2021 at 11:40 am
Reply to: Element no longer read-only after undo
February 4, 2021 at 11:40 amHi,
You still can delete an element with readonly content directly.
The following 2 lines are not needed.
rng.ReadOnlyContainer = False
rng.NonRemovableContainer = FalseRegards,
Ning
lefrac01 February 4, 2021 at 12:22 pm
Reply to: Element no longer read-only after undo
February 4, 2021 at 12:22 pmHello, thanks for the reply.
The requirement is for the content and also the element itself to be readonly.
Without both those lines the element is not deleted. If I leave only rng.NonRemovableContainer = False the element is deleted but is still editable after undo.
It looks like the undo feature is re-adding the XML content but not reapplying the readonly state.
nhu1 February 4, 2021 at 6:04 pm
Reply to: Element no longer read-only after undo
February 4, 2021 at 6:04 pmHi,
rng.ReadOnlyContainer = False
rng.NonRemovableContainer = FalseThe two lines about are not executed as commands. This is why they are not undoable.
At present, there is no workaround it. I will add the issue to the backlog of XMetaL 16.
Regards,
Ning
rozysharma October 18, 2021 at 1:44 am
Reply to: Element no longer read-only after undo
October 18, 2021 at 1:44 amAnother method is to restrict formatting and editing. Making your document a read-only file means that the document can be read or copied but not modified.doramas yt
-
AuthorPosts
- You must be logged in to reply to this topic.