docs

Working with Controls

Controls are used to define the appearance and behavior of screen areas.

Controls consist of:

The base class for all controls in OpenUI5 is sap.ui.core.Control. To inherit and extend the functionality, specific controls can either inherit from the base class, or from another control.


UI Control Constructors

A constructor is a special type of function that is called to create an object. The constructor uses values to set control properties, thus preparing the new object for use.

In OpenUI5, control constructors accept the following arguments in the specified order:

  1. An optional unique identifier of type string which must either be the first argument, or omitted altogether. If you omit the ID, the OpenUI5 framework automatically computes an ID. Specifying your own identifier allows your application to easily find the control and, for example, retrieve the current user input from it. Alternatively, you can keep a reference to the control in a variable.
  2. A simple object as mSettings parameter that defines values for any property, aggregation, association, or event.

The following code snippet shows an example of a constructor that is called to create a new text control saying “Hello World” with the specified tooltip and width:

// required from sap/m/Text
var oText = new Text("testText",
{text : "Hello World", tooltip: "This is an example tooltip", width: "100px"});

The above example is an abbreviated version of the following code snippet with a detailed list of statements, which is alternatively supported:

// required from sap/m/Text
var oText = new Text("testText"); 
oText.setText("Hello World");
oText.setTooltip("This is an example tooltip");
oText.setWidth("100px");

The supported parameters are documented in the API Reference of the respective control.

Related Information

Developing Controls