Merge pull request #1579 from MoritzBrueckner/canvas

CanvasScript: add getCanvas() function and improve docstrings
This commit is contained in:
Lubos Lenco 2020-02-19 21:40:01 +01:00 committed by GitHub
commit ce16c194a5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -77,17 +77,32 @@ class CanvasScript extends Trait {
onReady = f;
}
// Defines layout
/**
* Returns an element of the canvas.
* @param name The name of the element
* @return TElement
*/
public function getElement(name: String): TElement {
for (e in canvas.elements) if (e.name == name) return e;
return null;
}
// Returns canvas array of elements
/**
* Returns an array of the elements of the canvas.
* @return Array<TElement>
*/
public function getElements(): Array<TElement> {
return canvas.elements;
}
/**
* Returns the canvas object of this trait.
* @return TCanvas
*/
public function getCanvas(): Null<TCanvas> {
return canvas;
}
/**
* Set visibility of canvas
* @param visible Whether canvas should be visible or not