SetCurrentParent()
Pushes the current parent onto the stack and sets a new parent element. This allows you to manually control the parent hierarchy.
Syntax
Result = MaterialSB::SetCurrentParent(Parent)
Parameters
| Parameter | Description |
|---|---|
Parent |
The DOM element to set as the new current parent. |
Return Value
Returns the new current parent element (same as the input).
Remarks
Unlike container functions like Row() and Col() which automatically manage the parent stack, SetCurrentParent() gives you manual control. This is useful when you need to:
- Add content to a previously created element
- Work with custom DOM elements
- Navigate to a specific point in the hierarchy
Since this function pushes to the stack, remember to call CloseCurrentParent() when done.
Example
; Create a card and store reference
MaterialSB::Row()
myCard = MaterialSB::Card()
MaterialSB::CardContent()
MaterialSB::Append(MaterialSB::Paragraph("Initial content"))
MaterialSB::CloseCurrentParent()
MaterialSB::CloseCurrentParent()
MaterialSB::CloseCurrentParent()
; Later, add more content to the card
MaterialSB::SetCurrentParent(myCard)
MaterialSB::CardAction()
MaterialSB::Append(MaterialSB::Link("Learn More", @LearnMoreCallback()))
MaterialSB::CloseCurrentParent()
MaterialSB::CloseCurrentParent()