DisplayObject

extendsObject

Most primitive widget. Provides most basic widget behavior including draw function and standardized properties.

Properties#

nameTypeDefault ValueDescription
idstring(8-digit random)Identifies widget. Set this to make it searchable.
xstring or number0Can be either plain number or number with unit.
ystring or number0Can be either plain number or number with unit.
widthstring or number"100dp"Can be number, number with unit, "content", or "container". see sizing guide.
heightstring or number"100dp"Can be number, number with unit, "content", or "container". see sizing guide.
scaleXnumber1.0Fraction of number. This will multiply width.
scaleYnumber1.0Fraction of number. This will multiply height.
scalenumber1.0Set this to change both scaleX and scaleY at once.
alphanumber1.00.0 means transparent and 1.0 is fully opaque.
anglenumber00.0 means transparent and 1.0 is fully opaque.
elevationstring or number0Can be either plain number or number with unit.
cornerRadiusstring or number0Can be either plain number or number with unit.
presencebooleantrueIf true, this widget will affects other widgets' position and size.
visiblebooleantrueIf true, this widget will be drawn.
clippingbooleantrueIf true, content of this widget will be cropped if exceed the boundary.
suspendUpdatebooleantrueSet true to temporarily prevent update trigger.
backgroundColornumberapp.res.style.backgroundColorUse app.colors.* to set the color.
foregroundColornumberapp.res.style.foregroundColorUse app.colors.* to set the color.
borderColornumberthis.foregroundColorUse app.colors.* to set the color.
borderSizestring or number0Can be either plain number or number with unit.
paddingTopstring or number0Can be either plain number or number with unit.
paddingBottomstring or number0Can be either plain number or number with unit.
paddingLeftstring or number0Can be either plain number or number with unit.
paddingRightstring or number0Can be either plain number or number with unit.
paddingHorizontalstring or number0Set this to write both paddingLeft and paddingRight at once.
paddingVerticalstring or number0Set this to write both paddingTop and paddingBottom at once.
paddingsstring or number0Set this to write paddingTop, paddingBottom, paddingLeft and paddingRight.
borderSizestring or number0Can be either plain number or number with unit.
marginTopstring or number0Can be either plain number or number with unit.
marginBottomstring or number0Can be either plain number or number with unit.
marginLeftstring or number0Can be either plain number or number with unit.
marginRightstring or number0Can be either plain number or number with unit.
marginHorizontalstring or number0Set this to write both marginLeft and marginRight at once.
marginVerticalstring or number0Set this to write both marginTop and marginBottom at once.
marginsstring or number0Set this to write marginTop, marginBottom, marginLeft and marginRight.
alignSelfstring""Align position of this widget. See alignment guide.
hookTopToTopOfstring""ID of targeted widget. Only works if currently content of HookLayout.
hookTopToBottomOfstring""ID of targeted widget. Only works if currently content of HookLayout.
hookBottomToBottomOfstring""ID of targeted widget. Only works if currently content of HookLayout.
hookBottomToTopOfstring""ID of targeted widget. Only works if currently content of HookLayout.
hookLeftToLeftOfstring""ID of targeted widget. Only works if currently content of HookLayout.
hookLeftToRightOfstring""ID of targeted widget. Only works if currently content of HookLayout.
hookRightToRightOfstring""ID of targeted widget. Only works if currently content of HookLayout.
hookRightToLeftOfstring""ID of targeted widget. Only works if currently content of HookLayout.
onDrawfunction(empty function)Event listeners that you could set on .fiwl layout.
onUpdatefunction(empty function)Event listeners that you could set on .fiwl layout.
onSelectfunction(empty function)Event listeners that you could set on .fiwl layout.
onOptionfunction(empty function)Event listeners that you could set on .fiwl layout.
onScrollfunction(empty function)Event listeners that you could set on .fiwl layout.
onDragStartfunction(empty function)Event listeners that you could set on .fiwl layout.
onDragMovefunction(empty function)Event listeners that you could set on .fiwl layout.
onDragEndfunction(empty function)Event listeners that you could set on .fiwl layout.
onHoverStartfunction(empty function)Event listeners that you could set on .fiwl layout.
onHoverMovefunction(empty function)Event listeners that you could set on .fiwl layout.
onHoverEndfunction(empty function)Event listeners that you could set on .fiwl layout.
onAsyncCreatefunction(empty function)Event listeners that you could set on .fiwl layout.
onReadyfunction(empty function)Event listeners that you could set on .fiwl layout.
onSuspendfunction(empty function)Event listeners that you could set on .fiwl layout.
onDestroyfunction(empty function)Event listeners that you could set on .fiwl layout.

Read-only Properties#

NameTypeDescription
containerobjectGet this instance's container. See Layout Principle.
globalXnumberGet pre-calculated absolute horizontal position.
globalYnumberGet pre-calculated absolute vertical position.
measuredWidthnumberGet pre-calculated absolute width.
measuredHeightnumberGet pre-calculated absolute height.
measuredContentsWidthnumberMeasured width = "contents" value. Always returns 0 because DisplayObject does not contain anything.
measuredContentsHeightnumberMeasured height = "contents" value. Always returns 0 because DisplayObject does not contain anything.

Methods#

NameReturn TypeDescription
requestUpdatevoidManually request to re-render.
addEventListenervoidCalls app.event.addEventListener with this widget as context.
removeEventListenervoidCalls app.event.removeEventListener with this widget as context.

requestUpdate#

requestUpdate();

Manually request to re-render.

Return: void


addEventListener#

addEventListener(type, listener);

Calls app.event.addEventListener with this widget as context.

Parameters:

  1. type:(string type) One of listed event types above.
  2. listener: (function type) The function callback. Will be called on triggered.

Return: void


removeEventListener#

removeEventListener(type, listener);

Calls app.event.removeEventListener with this widget as context.

Parameters:

  1. type:(string type) One of listed event types above.
  2. listener: (function type) The function callback

Return: void


For Widget Developers#

caution

Widget development is not ready yet until modular widget support available. See development checklist.

Static Properties#

NameTypeDefault ValueDescription
parseContentsfunctionnullTells parser how to parse this widget's contents. Ignore this to keep default behavior.
customContentsKeystringnullTells parser which property that holds parsed contents. Ignore this to keep default behavior.
writableContentsbooleanfalseSet true to allow overwrite, but auto-update won't be triggered.
flagNoUpdateArray<string>[]Tells which properties should not trigger auto-update.
flagNoAnimateArray<string>[]Tells which properties should not trigger animation. (For future development)
flagForwardWeakMapArray<string>[]Tells which WeakMap with private properties inside.

Static Read-Only Properties#

NameTypeDescription
internalWeakMap<DisplayObject, any>Stores non-exposable properties as example measured values.

Methods#

NameReturn TypeDescription
asyncCreatePromise<void>Asynchronous version of constructor.
readyvoidExecuted just after the stage ready.
suspendvoidExecuted just before the interactive stage being destroyed.
drawArray<Object>Tells render engine how to draw.
drawBackgroundArray<Object>Aids any widgets to reuse this drawBackground function. Typically called before draw function.
drawPostEffectArray<Object>Aids any widgets to reuse this drawPostEffect function. Typically called after draw function.

asyncCreate#

async asyncCreate() {
...
}

Asynchronous version of constructor.

Return: Promise<void>.

caution

You have to resolve the Promise when the on going task is finished. Otherwise, the app will stuck at loading screen.


ready#

ready() {
...
}

Executed just after the stage ready. Much like ready event on stage, but this one is for any widgets.

Return: void


suspend#

suspend() {
...
}

Executed just after the stage ready. Much like ready event on stage, but this one is for any widgets.

Return: void


note

We will provide you guide of drawing with RenderAPI on widget. Stay tuned!