Class “NativeObject”

Object > NativeObject

Base class for all objects with a native implementation.

Constructor protected
Singleton No
Namespace tabris
Direct subclasses App, Device, FileSystem, InactivityTimer, Popup, Printer, NavigationBar, StatusBar, Tabris, Widget
JSX support No

Methods

off(type, listener, context?)

Removes all occurrences of listener that are bound to type and context from this widget.

In TypeScript you should use the alternative Listeners API, e.g. widget.onResize.off(listener); instead of widget.off('resize', listener}); The former provides more type information.

Parameter Type Optional Description
type string No The type of events to remove listeners for.
listener (event: EventObject<NativeObject>) => void No The listener function to remove.
context object Yes The context of the bound listener to remove.

Returns this

off(listeners)

Removes all listeners in the given object from the event type indicated by their key.

In TypeScript you should use the alternative Listeners API, e.g. widget.onResize.off(listener); instead of widget.off({resize: listener}); The former provides more type information.

Parameter Type Optional Description
listeners EventsObject No A key-value map where the keys are event types and the values are the listeners to deregister from these events, e.g. {tap: onTap, scroll: onScroll}.

Returns this

on(type, listener, context?)

Registers a listener function to be notified of events of the given type.

Parameter Type Optional Description
type string No The type of events to listen for.
listener (event: EventObject) => void No The listener function to register. This function will be called with an event object.

In TypeScript you should use the alternative Listeners API, e.g. widget.onResize(listener); instead of widget.on({resize: listener}); The former provides more type information. context | object | Yes | In the listener function, this will point to this object. If not present, the listener will be called in the context of this object.

Returns this

on(listeners)

Registers all listeners in the given object for the event type indicated by their key.

In TypeScript you should use the alternative Listeners API, e.g. widget.onResize(listener); instead of widget.on('resize', listener); The former provides more type information.

Parameter Type Optional Description
listeners {event: Listener} No A key-value map where the keys are event types and the values are the listeners to register for these events, e.g. {tap: onTap, scroll: onScroll}.

Returns this

once(type, listener, context?)

Same as on, but removes the listener after it has been invoked by an event.

In TypeScript you should use the alternative Listeners API, e.g. widget.onResize.once(listener); instead of widget.once('resize', listener); The former provides more type information.

Parameter Type Optional Description
type string No The type of the event to listen for.
listener (event: EventObject<NativeObject>) => void No The listener function to register. This function will be called with an event object.
context object Yes In the listener function, this will point to this object. If not present, the listener will be called in the context of this object.

Returns this

once(listeners)

Same as on, but removes the listener after it has been invoked by an event.

In TypeScript you should use the alternative Listeners API, e.g. widget.onResize.once(listener); instead of widget.once({resize: listener}); The former provides more type information.

Parameter Type Optional Description
listeners EventsObject No A key-value map where the keys are event types and the values are the listeners to register for these events, e.g. {tap: onTap, scroll: onScroll}.

Returns this

set(properties)

Sets all key-value pairs in the properties object as widget properties.

Parameter Type Optional Description
properties Properties<this> No  

Returns this

trigger(type)

Notifies all registered listeners for the given type.

In TypeScript you should use the alternative Listeners API, e.g. widget.myEvent.trigger(); instead of widget.trigger('myEvent'); The former provides more type information.

Parameter Type Optional Description
type string No The type of event to trigger

Returns this

trigger(type, object)

Passes the fields of the given object to all listeners registered for this event type.

In TypeScript you should use the alternative Listeners API, e.g. widget.myEvent.trigger(eventData); instead of widget.trigger('myEvent', eventData}); The former provides more type information.

Parameter Type Optional Description
type string No The type of event to trigger
object object No The data to pass to listener functions.

Returns this

trigger(type, eventObject)

Initializes the given eventObject and passes it to all listeners registered for this event type. If eventObject was already initialized its fields are copied to a new event object.

In TypeScript you should use the alternative Listeners API, e.g. widget.myEvent.trigger(eventObject); instead of widget.trigger('myEvent', eventObject}); The former provides more type information.

Parameter Type Optional Description
type string No The type of event to trigger
eventObject EventObject No An instance of EventObject (or a subclass) to pass to listener functions.

Returns this

Properties

cid

An application-wide unique identifier automatically assigned to all native objects on creation.

Type string
Settable No

This property can only be set via constructor. Once set, it cannot change anymore.

jsxProperties

When using JSX with TypeScript (.tsx files), the type of this property determines which JSX attributes are valid for this object.

Type JSXProperties<this>
Settable No

This property can only be set via constructor. Once set, it cannot change anymore.