HtmlElements class
A child-element collection on an HtmlElement. Reached through HtmlElement.ChildDomElements. Use Add to create new children and Item to look one up by ID after the fact.
With myToolWindow.RootDomElement
With .ChildDomElements.Add("header", "h1")
.Properties.innerText = "Hello"
End With
With .ChildDomElements.Add("body", "div")
.Properties.style.padding = "10px"
With .ChildDomElements.Add("greeting", "p")
.Properties.innerText = "World"
End With
End With
End With
Methods
Add
Creates a new child element under the parent HtmlElement and returns the new HtmlElement.
Syntax: htmlElements.Add( ElementID, TagName ) As HtmlElement
- ElementID
- required A DOM
idfor the new element. String. Pick distinct IDs across the tool window — they double as the key for Item lookups. - TagName
- required The HTML tag name. String. Standard tags (
"div","span","input","h1","label","img", …) work as expected; the IDE additionally accepts four custom-widget tags described in Tool-window DOM tags on the package overview:"chartjs","monaco","listview","virtuallistview".An
"iframe"shows a web page inside the tool window: set itssrcproperty to the page’s URL, and set it again to show another. The page scrolls, and follows its own links, and a"load"listener hears each page load. The page is a document of its own, so keys pressed while it has the focus go to it: an addin’s keyboard shortcuts do not fire there. Itsprefers-color-schemeis the one Windows sets for apps, not the IDE’s theme, so a page that follows it can be light in a dark IDE.
With myToolWindow.RootDomElement
' Standard DOM tags:
Set greeting = .ChildDomElements.Add("greeting", "h1")
Set entry = .ChildDomElements.Add("entryBox", "input")
' Custom-widget tags (see sample 11 / 12 / 13 / 14):
Set chart = .ChildDomElements.Add("cpuChart", "chartjs")
Set editor = .ChildDomElements.Add("myEditor", "monaco")
Set listview = .ChildDomElements.Add("itemsList", "listview")
Set virtList = .ChildDomElements.Add("bigList", "virtuallistview")
End With
Properties
Item
Looks up an existing child element by its ID. DefaultMember — so elements("greeting") is equivalent to elements.Item("greeting").
Syntax: htmlElements( ID ) As HtmlElement
- ID
- A Variant — typically the String ID assigned at Add time.