Pages: 1
Print
Author Topic: Remove an element from the Element List.  (Read 409 times)
anton
Member

Posts: 2


« on: February 21, 2018, 09:55:30 AM »

Hey Derek,

Our plugin highlights words in XML documents by embracing them into a new tag.
To allow that we add this tag to the document's DTD:

     LPDISPATCH p = docOwner.get_doctype();
     DOMDocumentType dtd(p);
     dtd.addElement(pszTag, "", TRUE, TRUE);

Having this done we can start highlighting words.
As a result this tag gets viewable in the Element List pane.

However it remains there even after the highlight has been cleared and all occurances of the tags removed from the document.

Any chance to remove it from the Element List so that it no longer irritates customers?

thank you,
Anton.
Logged
Derek Read
Program Manager (XMetaL)
Administrator
Member

Posts: 2564



WWW
« Reply #1 on: February 21, 2018, 02:26:03 PM »

When you use addElement() you are modifying the in-memory model of the DTD (which is why it is used in the event On_DTD_Open_Complete). That change is permanent until the DTD is reloaded. There is no equivalent API for removing such definitions from the in-memory model of the DTD.

If the only issue is that you don't want the user to insert the element using the Element List you can modify what appears in the Element List using the On_Update_ElementList event and the API ElementList.RemoveItem(elemname). This event fires each time the element list is updated which gives you the flexibility to include logic that decides whether or not to remove an item under specific circumstances. If you want it to never be listed then your logic would just always remove it.

This will not stop a user from pasting the element into a document or typing it into Plain Text view. That would require the DTD to be reloaded.
Logged
anton
Member

Posts: 2


« Reply #2 on: February 26, 2018, 03:43:56 AM »

Thank you, Derek, that's exactly what we need!
Logged
Pages: 1
Print
Jump to:  

email us