Class “Widget”

Object > NativeObject > Widget

Base class for all widgets

Type: Widget<TData> extends NativeObject
Generics: TData: The type of the data object. Must be a subclass of object and defaults to any.
Constructor: protected
Singleton: No
Namespace: tabris
Direct subclasses: Action, ActivityIndicator, Button, CameraView, CheckBox, Composite, ImageView, PdfView, Picker, ProgressBar, RadioButton, Slider, Switch, TextInput, TextView, ToggleButton, Video, WebView
JSX Support: No

See also:

Understanding layouts in Tabris.js
Understanding gesture events in Tabris.js
JSX A Widget with padding [► Run in Playground]
JSX A card style Widget with corner radius and elevation [► Run in Playground]
JS A Widget with a linear-gradient background [► Run in Playground]
JS Using touch events on a Widget [► Run in Playground]
JSX widget-elevation.jsx [► Run in Playground]
JSX widget-exclude-from-layout.jsx [► Run in Playground]
JSX widget-highlightontouch.jsx [► Run in Playground]
JS widget-touch.js [► Run in Playground]

Methods

animate(properties, options)

Starts an animation that transforms the given properties from their current values to the given ones. Supported properties are transform and opacity. Returns a promise that is resolved once the animation is completed and is rejected if the animation is aborted.

Parameter Type Description
properties {
  transform: Transformation, // optional
  opacity: number // optional
}
The properties and target values to animate.
options AnimationOptions Configures the animation itself.

Returns: Promise

appendTo(parent)

Appends this widget to the given parent. The parent widget must support children (extending Composite). If the widget already has a parent, it is removed from the old parent.

Parameter Type Description
parent Composite  

Returns: this

detach()

Removes this widget from its parent.

Returns: this

dispose()

Removes this widget from its parent and destroys it. Also disposes of all its children. Triggers a remove event on the parent and a dispose event on itself. The widget can no longer be used.

Returns: undefined

insertAfter(widget)

Inserts this widget directly after the given widget. If the widget already has a parent, it is removed from the old parent.

Parameter Type Description
widget Widget  

Returns: this

insertBefore(widget)

Inserts this widget directly before the given widget. If the widget already has a parent, it is removed from the old parent.

Parameter Type Description
widget Widget  

Returns: this

isDisposed()

Returns true if the widget has been disposed, otherwise false.

Returns: boolean

parent()

Returns the parent of this widget or null if this widget is not appended to a parent.

Returns: Composite

parent(selector)

Returns the first (nearest) parent of this widget that matches the given selector, or null if no parent matches.

Parameter Type Description
selector Selector A selector expression or a predicate function to filter the results.

Returns: Result

siblings(selector?)

Returns a (possibly empty) collection of all siblings of this widget that match the given selector.

Parameter Type Description
selector Selector A selector expression or a predicate function to filter the results. Optional.

Returns: WidgetCollection

Protected Methods

These methods are accessible only in classes extending Widget.

_setParent(parent, index?)

Sets the parent of the widget. If an index is given the widget will be inserted at that position.

Parameter Type Description
parent Composite  
index number Optional.

Returns: undefined

Properties

absoluteBounds

The actual location and size of the widget, relative to contentView.

Type: Bounds
Settable: No
Change Event: Not supported

background

The background of the widget. If given a plain string it is interpreted first as a gradient, then as a color, and finally as an image path, whichever passes first. Use object literals or instances of LinearGradient, Color or Image to avoid any ambiguity.

Type: LinearGradientValue
| ColorValue
| ImageValue
Settable: Yes
Change Event: backgroundChanged

baseline

The vertical position of the widget’s baseline relative to a sibling widget. Value true is treated like 'prev()' and aligns it with the previous sibling.

Type: SiblingReferenceValue
| 'auto'
| true
Default: 'auto'
Settable: Yes
Change Event: baselineChanged

bottom

The position of the widget’s bottom edge relative to the parent or a sibling widget.

Type: ConstraintValue
Default: 'auto'
Settable: Yes
Change Event: bottomChanged

bounds

The actual location and size of the widget, relative to its parent.

Type: Bounds
Settable: No
Change Event: boundsChanged

centerX

The horizontal position of the widget’s center relative to the parent’s center. Value true is treated like 0 and puts it at the exact center without offset.

Type: Offset
| 'auto'
| true
Default: 'auto'
Settable: Yes
Change Event: centerXChanged

centerY

The vertical position of the widget’s center relative to the parent’s center. Value true is treated like 0 and puts it at the exact center without offset.

Type: Offset
| 'auto'
| true
Default: 'auto'
Settable: Yes
Change Event: centerYChanged

class

A class name or a whitespace separated list of class names to identify the widget. Class names are arbitrary strings that describe a state or a category and help to select widgets using a selector expression. A class name may only contain alphanumeric characters, _ and -. Class names can also be added or removed using the field classList.

Type: string
Settable: Yes
Change Event: classChanged

classList

Provides convenient access to the list of class names set to this widget. Class names can either be set using the class property or by modifying the classList directly.

Type: string[]
Settable: Yes
Change Event: classListChanged

cornerRadius

Configure a widget to have equally rounded corners. The widget content is clipped by the rounded corners.

Type: number
Settable: Yes
Change Event: cornerRadiusChanged

See also:

JSX widget-cornerradius.jsx [► Run in Playground]

data

A general-purpose property that may be set to any object. Unlike other properties, data forwards change events from the object it contains. As it is initialized with an empty instance of ObservableData, modifying this initial data object also causes a PropertyChangedEvent for data to be fired.

Important: If data is assigned a plain object, that object will be converted to an ObservableData instance, so the original object will not be identical with the new data value. If set to any other object the new value will be the same instance.

When set as an attribute (via JSX or a widget factory) it has a special treatment: Unlike other properties it is set after the listeners have been registered. This is so to allow passing a data change listener (via ‘onDataChanged’ attribute) that will be invoked for the initial data value immediately.

Type: TData
Settable: Yes
Change Event: dataChanged

elevation

The position of the widget on the z-axis. Setting an elevation casts a shadow in the shape of the widget.

To have the shadow properly applied on Android it is required to set the background on the widget as well.

Type: number
Settable: Yes
Change Event: elevationChanged

See also:

JSX widget-elevation.jsx [► Run in Playground]

enabled

Whether the widget can be interacted with.

Type: boolean
Default: true
Settable: Yes
Change Event: enabledChanged

excludeFromLayout

If set to true the widget will be invisible and ignored in the layout of the parent. Visually it is treated like it was not attached to its parent, but it will still included in the return value of children().

Type: boolean
Default: false
Settable: Yes
Change Event: excludeFromLayoutChanged

height

The height of the widget.

Type: Dimension | 'auto'
Default: 'auto'
Settable: Yes
Change Event: heightChanged

highlightOnTouch

Whether the widget should show visual feedback while touched. Enabling highlightOnTouch will not prevent the touch event from being propagated to the parent widget.

Type: boolean
Default: false
Settable: Yes
Change Event: highlightOnTouchChanged

See also:

JSX widget-highlightontouch.jsx [► Run in Playground]

id

A string to identify the widget by using selectors. IDs are optional. It is strongly recommended that they are unique within any component.

Type: string
Settable: Yes
Change Event: idChanged

layoutData

Provides information for a widget to be used by the parent when determining its size and position. While this property accepts any valid LayoutData expression (see LayoutDataValue), it will always return an instance of the class LayoutData.

Widget provides an alias property for each property of LayoutData. Setting these properties will change the value of the layoutData property, while getting them is the same as accessing them via the layoutData property. I.e. widget.left === widget.layoutData.left.

There are multiple presets for layoutData available as static properties on the LayoutData class: center, [stretch](/latest/api/LayoutData.html#stretch), stretchX and [stretchY](/latest/api/LayoutData.html#stretchy). They may be set directly (new TextView({layoutData: LayoutData.stretch});), via string (e.g. new TextView({layoutData: 'stretch'});), or in JSX via a special shorthand syntax: <TextView stretch/>. The presets can be merged with widget properties, e.g. <TextView stretch left={10}/> or <TextView stretchX centerY/>

Type: LayoutDataValue
Default: LayoutData
Settable: Yes
Change Event: layoutDataChanged

left

The position of the widget’s left edge relative to the parent or a sibling widget.

Type: ConstraintValue
Default: 'auto'
Settable: Yes
Change Event: leftChanged

opacity

Opacity of the entire widget, in the range [0..1]. Can be used for fade animations.

Type: number
Default: 1
Settable: Yes
Change Event: opacityChanged

padding

Additional space to add inside the widgets bounds.

Type: BoxDimensions | null
Settable: By Constructor or JSX
Change Event: Not supported

See also:

JSX widget-padding.jsx [► Run in Playground]

The position of the widget’s right edge relative to the parent or a sibling widget.

Type: ConstraintValue
Default: 'auto'
Settable: Yes
Change Event: rightChanged

top

The position of the widget’s top edge relative to the parent or a sibling widget.

Type: ConstraintValue
Default: 'auto'
Settable: Yes
Change Event: topChanged

transform

Modifications to the widget’s shape, size, or position. Can be used for animations. Note: In Android the transform property does not affect the bounds property, while it does so in iOS.

Type: Transformation
Settable: Yes
Change Event: transformChanged

visible

If set to false the widget will be invisible, but still occupy space in the parents layout. Visually it is treated like a widget with an opacity of 0, but in addition the widget can also not be interacted with anymore.

Type: boolean
Default: true
Settable: Yes
Change Event: visibleChanged

width

The width of the widget.

Type: Dimension | 'auto'
Default: 'auto'
Settable: Yes
Change Event: widthChanged

Events

tap

Fired once when a finger briefly touched the widget.

EventObject Type: WidgetTapEvent<Widget>

Property Type Description
touches [{x: number, y: number}] Touch coordinates relative to the origin coordinates of the widget.

longPress

Fired after pressing a widget for a specific amount of time (about a second), and again on lifting the finger.

EventObject Type: WidgetLongPressEvent<Widget>

Property Type Description
state 'start'
| 'end'
| 'cancel'
‘start’ when the widget has been hold down long enough, ‘end’ when the finger has been lifted and ‘cancel’ when the gesture has been interrupted.
touches [{x: number, y: number}] Touch coordinates relative to the origin coordinates of the widget.

See also:

JS widget-longpress-to-drag.js [► Run in Playground]

pan

Fired continuously after a finger touching the widget moved for a certain distance.

EventObject Type: WidgetPanEvent<Widget>

Property Type Description
state 'start'
| 'change'
| 'end'
| 'cancel'
‘start’ when the finger starts moving, ‘change’ while the finger is moving, ‘end’ when the finger has been lifted and ‘cancel’ when the gesture has been interrupted.
touches [{x: number, y: number}] Touch coordinates relative to the origin coordinates of the widget.
translationX number Current horizontal touch offset relative to the first touch.
translationY number Current vertical touch offset relative to the first touch.
velocityX number Current horizontal velocity in pixels per second.
velocityY number Current vertical velocity in pixels per second.

panUp

Fired when a finger starts moving up.

EventObject Type: WidgetPanEvent<Widget>

Property Type Description
state 'start'
| 'change'
| 'end'
| 'cancel'
‘start’ when the finger starts moving, ‘change’ while the finger is moving, ‘end’ when the finger has been lifted and ‘cancel’ when the gesture has been interrupted.
touches [{x: number, y: number}] Touch coordinates relative to the origin coordinates of the widget.
translationX number Current horizontal touch offset relative to the first touch.
translationY number Current vertical touch offset relative to the first touch.
velocityX number Current horizontal velocity in pixels per second.
velocityY number Current vertical velocity in pixels per second.

panDown

Fired when a finger starts moving down.

EventObject Type: WidgetPanEvent<Widget>

Property Type Description
state 'start'
| 'change'
| 'end'
| 'cancel'
‘start’ when the finger starts moving, ‘change’ while the finger is moving, ‘end’ when the finger has been lifted and ‘cancel’ when the gesture has been interrupted.
touches [{x: number, y: number}] Touch coordinates relative to the origin coordinates of the widget.
translationX number Current horizontal touch offset relative to the first touch.
translationY number Current vertical touch offset relative to the first touch.
velocityX number Current horizontal velocity in pixels per second.
velocityY number Current vertical velocity in pixels per second.

panLeft

Fired when a finger starts moving left.

EventObject Type: WidgetPanEvent<Widget>

Property Type Description
state 'start'
| 'change'
| 'end'
| 'cancel'
‘start’ when the finger starts moving, ‘change’ while the finger is moving, ‘end’ when the finger has been lifted and ‘cancel’ when the gesture has been interrupted.
touches [{x: number, y: number}] Touch coordinates relative to the origin coordinates of the widget.
translationX number Current horizontal touch offset relative to the first touch.
translationY number Current vertical touch offset relative to the first touch.
velocityX number Current horizontal velocity in pixels per second.
velocityY number Current vertical velocity in pixels per second.

panRight

Fired when a finger starts moving right.

EventObject Type: WidgetPanEvent<Widget>

Property Type Description
state 'start'
| 'change'
| 'end'
| 'cancel'
‘start’ when the finger starts moving, ‘change’ while the finger is moving, ‘end’ when the finger has been lifted and ‘cancel’ when the gesture has been interrupted.
touches [{x: number, y: number}] Touch coordinates relative to the origin coordinates of the widget.
translationX number Current horizontal touch offset relative to the first touch.
translationY number Current vertical touch offset relative to the first touch.
velocityX number Current horizontal velocity in pixels per second.
velocityY number Current vertical velocity in pixels per second.

panHorizontal

Fired when a finger starts moving left or right.

EventObject Type: WidgetPanEvent<Widget>

Property Type Description
state 'start'
| 'change'
| 'end'
| 'cancel'
‘start’ when the finger starts moving, ‘change’ while the finger is moving, ‘end’ when the finger has been lifted and ‘cancel’ when the gesture has been interrupted.
touches [{x: number, y: number}] Touch coordinates relative to the origin coordinates of the widget.
translationX number Current horizontal touch offset relative to the first touch.
translationY number Current vertical touch offset relative to the first touch.
velocityX number Current horizontal velocity in pixels per second.
velocityY number Current vertical velocity in pixels per second.

panVertical

Fired when a finger starts moving up or down.

EventObject Type: WidgetPanEvent<Widget>

Property Type Description
state 'start'
| 'change'
| 'end'
| 'cancel'
‘start’ when the finger starts moving, ‘change’ while the finger is moving, ‘end’ when the finger has been lifted and ‘cancel’ when the gesture has been interrupted.
touches [{x: number, y: number}] Touch coordinates relative to the origin coordinates of the widget.
translationX number Current horizontal touch offset relative to the first touch.
translationY number Current vertical touch offset relative to the first touch.
velocityX number Current horizontal velocity in pixels per second.
velocityY number Current vertical velocity in pixels per second.

swipeUp

Fired when a finger moves up quickly.

EventObject Type: WidgetSwipeEvent<Widget>

Property Type Description
touches [{x: number, y: number}] Touch coordinates relative to the origin coordinates of the widget.

swipeDown

Fired when a finger moves down quickly.

EventObject Type: WidgetSwipeEvent<Widget>

Property Type Description
touches [{x: number, y: number}] Touch coordinates relative to the origin coordinates of the widget.

swipeLeft

Fired when a finger moves left quickly.

EventObject Type: WidgetSwipeEvent<Widget>

Property Type Description
touches [{x: number, y: number}] Touch coordinates relative to the origin coordinates of the widget.

swipeRight

Fired when a finger moves right quickly.

EventObject Type: WidgetSwipeEvent<Widget>

Property Type Description
touches [{x: number, y: number}] Touch coordinates relative to the origin coordinates of the widget.

touchStart

Fired when a widget is touched. See Touch Events.

EventObject Type: WidgetTouchEvent<Widget>

Property Type Description
touches [{x: number, y: number, absoluteX: number, absoluteY: number}] Touch coordinates relative to the origin coordinates of the widget.

touchMove

Fired repeatedly while swiping across the screen.

EventObject Type: WidgetTouchEvent<Widget>

Property Type Description
touches [{x: number, y: number, absoluteX: number, absoluteY: number}] Touch coordinates relative to the origin coordinates of the widget.

touchEnd

Fired when a touch ends on the same widget than it started on.

EventObject Type: WidgetTouchEvent<Widget>

Property Type Description
touches [{x: number, y: number, absoluteX: number, absoluteY: number}] Touch coordinates relative to the origin coordinates of the widget.

touchCancel

Fired instead of touchEnd when the touch ends on another widget than it started on.

EventObject Type: WidgetTouchEvent<Widget>

Property Type Description
touches [{x: number, y: number, absoluteX: number, absoluteY: number}] Touch coordinates relative to the origin coordinates of the widget.

resize

Fired when the widget’s size has changed.

EventObject Type: WidgetResizeEvent<Widget>

Property Type Description
height number The height of the widget in dip.
left number The horizontal offset from the parent’s left edge in dip.
top number The vertical offset from the parent’s top edge in dip.
width number The width of the widget in dip.

dispose

Fired when the widget is about to be disposed. At this point the widget and its children are still accessible.

EventObject Type: EventObject<Widget>

This event has no additional parameter.

Change Events

idChanged

Fired when the id property has changed.

EventObject Type: PropertyChangedEvent<Widget, string>

Property Type Description
value string The new value of id.

classChanged

Fired when the class property has changed.

EventObject Type: PropertyChangedEvent<Widget, string>

Property Type Description
value string The new value of class.

classListChanged

Fired when the classList property has changed.

EventObject Type: PropertyChangedEvent<Widget, Array>

Property Type Description
value string[] The new value of classList.

enabledChanged

Fired when the enabled property has changed.

EventObject Type: PropertyChangedEvent<Widget, boolean>

Property Type Description
value boolean The new value of enabled.

excludeFromLayoutChanged

Fired when the excludeFromLayout property has changed.

EventObject Type: PropertyChangedEvent<Widget, boolean>

Property Type Description
value boolean The new value of excludeFromLayout.

visibleChanged

Fired when the visible property has changed.

EventObject Type: PropertyChangedEvent<Widget, boolean>

Property Type Description
value boolean The new value of visible.

layoutDataChanged

Fired when the layoutData property has changed.

EventObject Type: PropertyChangedEvent<Widget, LayoutDataValue>

Property Type Description
value LayoutDataValue The new value of layoutData.

leftChanged

Fired when the left property has changed.

EventObject Type: PropertyChangedEvent<Widget, ConstraintValue>

Property Type Description
value ConstraintValue The new value of left.

rightChanged

Fired when the right property has changed.

EventObject Type: PropertyChangedEvent<Widget, ConstraintValue>

Property Type Description
value ConstraintValue The new value of right.

topChanged

Fired when the top property has changed.

EventObject Type: PropertyChangedEvent<Widget, ConstraintValue>

Property Type Description
value ConstraintValue The new value of top.

bottomChanged

Fired when the bottom property has changed.

EventObject Type: PropertyChangedEvent<Widget, ConstraintValue>

Property Type Description
value ConstraintValue The new value of bottom.

widthChanged

Fired when the width property has changed.

EventObject Type: PropertyChangedEvent<Widget, Dimension | 'auto'>

Property Type Description
value Dimension | 'auto' The new value of width.

heightChanged

Fired when the height property has changed.

EventObject Type: PropertyChangedEvent<Widget, Dimension | 'auto'>

Property Type Description
value Dimension | 'auto' The new value of height.

centerXChanged

Fired when the centerX property has changed.

EventObject Type: PropertyChangedEvent<Widget, Offset
| 'auto'
| true>

Property Type Description
value Offset
| 'auto'
| true
The new value of centerX.

centerYChanged

Fired when the centerY property has changed.

EventObject Type: PropertyChangedEvent<Widget, Offset
| 'auto'
| true>

Property Type Description
value Offset
| 'auto'
| true
The new value of centerY.

baselineChanged

Fired when the baseline property has changed.

EventObject Type: PropertyChangedEvent<Widget, SiblingReferenceValue
| 'auto'
| true>

Property Type Description
value SiblingReferenceValue
| 'auto'
| true
The new value of baseline.

elevationChanged

Fired when the elevation property has changed.

EventObject Type: PropertyChangedEvent<Widget, number>

Property Type Description
value number The new value of elevation.

cornerRadiusChanged

Fired when the cornerRadius property has changed.

EventObject Type: PropertyChangedEvent<Widget, number>

Property Type Description
value number The new value of cornerRadius.

boundsChanged

Fired when the bounds property has changed.

EventObject Type: PropertyChangedEvent<Widget, Bounds>

Property Type Description
value Bounds The new value of bounds.

backgroundChanged

Fired when the background property has changed.

EventObject Type: PropertyChangedEvent<Widget, LinearGradientValue
| ColorValue
| ImageValue>

Property Type Description
value LinearGradientValue
| ColorValue
| ImageValue
The new value of background.

opacityChanged

Fired when the opacity property has changed.

EventObject Type: PropertyChangedEvent<Widget, number>

Property Type Description
value number The new value of opacity.

transformChanged

Fired when the transform property has changed.

EventObject Type: PropertyChangedEvent<Widget, Transformation>

Property Type Description
value Transformation The new value of transform.

highlightOnTouchChanged

Fired when the highlightOnTouch property has changed.

EventObject Type: PropertyChangedEvent<Widget, boolean>

Property Type Description
value boolean The new value of highlightOnTouch.

dataChanged

Fired when the data property has changed.

EventObject Type: PropertyChangedEvent<Widget, TData>

Property Type Description
value TData The new value of data.

Dimension

  • JavaScript Type: number
  • TypeScript Type: tabris.Dimension, an alias for number

A positive float, or 0, representing device independent pixels (DIP).

BoxDimensions

  • JavaScript Type: Object or string or Array.
  • TypeScript Type: tabris.BoxDimensions

The bounds of a rectangle in relation to the four edges of a containing element in DIP (device independent pixel). By default it is a plain object implementing the following interface:

interface BoxDimensions {
  left?: number;
  right?: number;
  top?: number;
  bottom?: number;
}

All properties are dimension and optional. Omitted properties are treated as 0.

As a shorthand a list of four dimensions is also accepted. This follow the order of [top, right, bottom, left], with missing entries being filled in by the entry of the opposing dimension. If only one entry is given it is used for all dimensions:

[1, 2, 3, 4] // {top: 1, right: 2, bottom: 3, left: 4};
[1, 2, 3] // {top: 1, right: 2, bottom: 3, left: 2};
[1, 2] // {top: 1, right: 2, bottom: 1, left: 2};
[1] // {top: 1, right: 1, bottom: 1, left: 1};

A space separated string list is also accepted instead of an array, with or without px as a unit.

Examples:

widget.padding = {left: 8, right: 8, top: 0, bottom: 0};
widget.padding = {left: 10, right: 10};
widget.padding = [0, 8];
widget.padding = [1, 10, 2, 10];
widget.padding = '10px 11px 12px 13px';
widget.padding = '10 11 12 13';
widget.padding = '0 8';

Bounds

  • JavaScript Type: Object
  • TypeScript Type: tabris.Bounds

The bounds of a rectangle in relation to the top-left corner of a containing element in DIP (device independent pixel). This is a plain object implementing the following interface:

interface Bounds {
  left: number;
  top: number;
  width: number;
  height: number;
}

Explanation:

Property Description
left The horizontal offset from the parent’s left edge
top The vertical offset from the parent’s top edge
width The width of the widget
height The height of the widget

Example:

const buttonRight = button.bounds.left + button.bounds.width;

AnimationOptions

Options of the animate() method. They have to implement the following interface:

interface AnimationOptions {
  delay?: number;
  duration?: number;
  easing?: "linear" | "ease-in" | "ease-out" | "ease-in-out";
  repeat?: number;
  reverse?: boolean;
  name?: string;
}

Each property has a default value if omitted:

Property Default Description
delay 0 Time until the animation starts in ms.
duration (platform default) Animation duration in ms.
easing linear Acceleration/deceleration curve
repeat 0 Number of times to repeat the animation. Use Infinity to repeat indefinitely.
reverse true Should the direction of the animation alternative on every repeat.
name undefined No effect, but will be given in animation events.

Transformation

A Transformation is any object implementing the following interface:

interface Transformation {
  rotation?: number;
  scaleX?: number;
  scaleY?: number;
  translationX?: number;
  translationY?: number;
  translationZ?: number;
}

On iOS translationZ is not supported and will be ignored.

Each property has a default value if omitted:

Property Default Description
rotation 0 Clock-wise rotation in radians.
scaleX 1 Horizontal scale factor.
scaleY 1 Vertical scale factor.
translationX 0 Horizontal translation (shift) in DIP (device independent pixels).
translationY 0 Vertical translation (shift) in DIP.
translationZ 0 Z-axis translation (shift) in DIP.

Example:

{scaleX: 2, scaleY: 2, rotation: Math.PI * 0.75}

This transformation will make the widget twice as big and rotate it by 135°.

Properties<Widget>

The generic Properties type describes an object containing any number of key-value pairs corresponding to the settable properties of a given widget class. Such objects can be givin to a widget constructor or set method so set multiple widget properties simultaneously.

// Valid:
video.set({autoPlay: true, url: './myvideo.mp4'});
// Invalid: duration is read-only and can not be set!
video.set({duration: 1000});

The TypeScript interface always requires the widget class type parameter:

// Correct:
let props: Properties<Video> = {autoPlay: true, url: './myvideo.mp4'};
// Compiler Error: duration is read-only and can not be set!
props = {duration: 1000};

This interface is especially relevant when writing custom components in TypeScript, where it is needed to define the constructor:

class CustomComponent extends Composite {

  constructor(properties: Properties<CustomComponent>) {
    super(properties);
  }

}
interface PropertyChangedEvent<TargetType, ValueType> extends EventObject<TargetType> {
  readonly value: ValueType
}