Module: delite/Widget

delite/Widget

require(["delite/Widget"], function (Widget) { new Widget(); })

Base class for all widgets, i.e. custom elements that appear visually.
Source:
Source:

Members

containerNode :DomNode

Designates where children of the source DOM node will be placed. "Children" in this case refers to both DOM nodes and widgets.

containerNode must be defined for any widget that accepts innerHTML (like ContentPane or BorderContainer or even Button), and conversely is undefined for widgets that don't, like TextBox.

Type:
  • DomNode
Default Value:
  • undefined
Source:

focused :boolean

This widget or a widget it contains has focus, or is "active" because it was recently clicked.
Type:
  • boolean
Default Value:
  • false
Source:

register :delite/register

Convenience pointer to register class. Used by buildRendering() functions produced from handlebars! / template.
Type:
  • delite/register
Source:

Methods

attachedCallback()

Called when the widget is first inserted into the document. If widget is created programatically then app must call startup() to trigger this method.
Source:

buildRendering()

Construct the UI for this widget, filling in subnodes and/or text inside of this. Most widgets will leverage delite/handlebars! to implement this method.
Source:

createdCallback()

Kick off the life-cycle of a widget.
Source:

defer(fcn, delay)

Wrapper to setTimeout to avoid deferred functions executing after the originating widget has been destroyed. Returns an object handle with a remove method (that returns null) (replaces clearTimeout).
Parameters:
Name Type Description
fcn Object Function reference.
delay Object Delay, defaults to 0.
Inherited From:
Source:

destroy()

Destroy this widget and its descendants.
Source:

emit()

Signal that a synthetic event occurred, ex:


myWidget.emit("attrmodified-selectedChildWidget", {}).

Emits an event of specified type, based on eventObj. Also calls onType() method, if present, and returns value from that method. Modifies eventObj by adding missing parameters (bubbles, cancelable, widget).
Inherited From:
Source:

findCustomElements(Element)

Search subtree under root returning custom elements found.
Parameters:
Name Type Argument Description
Element <optional>
root Node to search under.
Inherited From:
Source:

getChildren()

Returns all direct children of this widget, i.e. all widgets or DOM node underneath this.containerNode whose parent is this widget. Note that it does not return all descendants, but rather just direct children.

The result intentionally excludes internally created widgets (a.k.a. supporting widgets) outside of this.containerNode.

Source:

getEnclosingWidget()

Returns the widget whose DOM tree contains the specified DOMNode, or null if the node is not contained within the DOM tree of any widget
Source:

getParent()

Returns the parent widget of this widget.
Source:

isFocusable()

Return true if this widget can currently be focused and false if not
Source:

isLeftToRight()

Return this widget's explicit or implicit orientation (true for LTR, false for RTL)
Source:

mix()

Set a hash of properties on a Stateful instance
Inherited From:
Source:
Example
myObj.mix({
	foo: "Howdy",
	bar: 3
})

on()

Call specified function when event occurs, ex: myWidget.on("click", function () { ... }).
Inherited From:
Source:

onBlur()

Called when the widget stops being "active" because focus moved to something outside of it, or the user clicked somewhere outside of it, or the widget was hidden.
Source:

onFocus(e)

Called when the widget becomes "active" because it or a widget inside of it either has focus, or has recently been clicked.
Parameters:
Name Type Description
e event A focus event.
Source:

own()

Track specified handles and remove/destroy them when this instance is destroyed, unless they were already removed/destroyed manually.
Inherited From:
Source:

placeAt(reference, position)

Place this widget somewhere in the DOM based on standard domConstruct.place() conventions.

A convenience function provided in all _Widgets, providing a simple shorthand mechanism to put an existing (or newly created) Widget somewhere in the dom, and allow chaining.
Parameters:
Name Type Argument Description
reference String | DomNode | Widget Widget, DOMNode, or id of widget or DOMNode
position String | Int <optional>
If reference is a widget (or id of widget), and that widget has an ".addChild" method, it will be called passing this widget instance into that method, supplying the optional position index passed. In this case position (if specified) should be an integer.

If reference is a DOMNode (or id matching a DOMNode but not a widget), the position argument can be a numeric index or a string "first", "last", "before", or "after", same as dojo/dom-construct::place().

Source:

postCreate()

Processing after the DOM fragment is created

Called after the DOM fragment has been created, but not necessarily added to the document. Do not include any operations which rely on node dimensions or placement.
Source:

preCreate()

Processing before buildRendering()
Source:

processConstructorParameters()

Called after Object is created to process parameters passed to constructor.
Inherited From:
Source:

startup()

Processing after the DOM fragment is added to the document

Called after a widget and its children have been created and added to the page, and all related widgets have finished their create() cycle, up through postCreate().

Note that startup() may be called while the widget is still hidden, for example if the widget is inside a hidden deliteful/Dialog or an unselected tab of a deliteful/TabContainer. For widgets that need to do layout, it's best to put that layout code inside resize(), and then extend delite/_LayoutWidget so that resize() is called when the widget is visible.

Source:

watch()

Watches a property for changes.
Inherited From:
Source: