Class sap.m.TextModule: sap/m/Text

extends Control
implements IShrinkable

The Text control can be used for embedding longer text paragraphs, that need text wrapping, into your application.

Constructor Summary
new sap.m.Text(sId?, mSettings?)Constructor for a new Text.
Field Summary
cacheLineHeightDetermines per instance whether line height should be cached or not.
ellipsisEllipsis(…) text to indicate more text when clampText function is used.
normalLineHeightDefault line height value as a number when line-height is normal.
Events borrowed from class sap.ui.core.Control
Method Summary
sap.m.Text.extend(sClassName, oClassInfo?, FNMetaImpl?)Creates a new subclass of class sap.m.Text with name sClassName and enriches it with the information contained in oClassInfo.
sap.m.Text.getMetadata()Returns a metadata object for class sap.m.Text.
sap.m.Text.setNodeValue(oDomRef, sNodeValue?)To prevent from the layout thrashing of the textContent call, this method first tries to set the nodeValue of the first child if it exists.
bindText(oBindingInfo)Binds property text to model data.
clampHeight(oDomRef?)Sets the max-height to support maxLines property.
clampText(oDomRef?, iStartPos?, iEndPos?)Clamps the wrapping text according to max lines and returns the found ellipsis position.
getClampHeight(oDomRef?)Returns the max height according to max lines and line height calculation.
getLineHeight(oDomRef?)Caches and returns the computed line height of the text.
getMaxLines()Gets current value of property maxLines.
getText()Gets current value of property text.
getTextAlign()Gets current value of property textAlign.
getTextDirection()Gets current value of property textDirection.
getTextDomRef()Returns the text node container's DOM reference.
getWidth()Gets current value of property width.
getWrapping()Gets current value of property wrapping.
hasMaxLines()Determines whether max lines should be rendered or not.
setMaxLines(iMaxLines)Sets a new value for property maxLines.
setText(sText)Sets a new value for property text.
setTextAlign(sTextAlign)Sets a new value for property textAlign.
setTextDirection(sTextDirection)Sets a new value for property textDirection.
setWidth(sWidth)Sets a new value for property width.
setWrapping(bWrapping)Sets a new value for property wrapping.
unbindText()Unbinds property text from model data.
Constructor Detail
new sap.m.Text(sId?, mSettings?)
Constructor for a new Text.

Accepts an object literal mSettings that defines initial property values, aggregated and associated objects as well as event handlers. See sap.ui.base.ManagedObject for a general description of the syntax of the settings object.

The supported settings are:

In addition, all settings applicable to the base type sap.ui.core.Control can be used as well.

Parameters:
{string}sId? ID for the new control, generated automatically if no ID is given
{object}mSettings? Initial settings for the new control
Field Detail
cacheLineHeight: boolean
Determines per instance whether line height should be cached or not.

Default value is true.

Since:
1.22
ellipsis: string
Ellipsis(…) text to indicate more text when clampText function is used.

Can be overwritten with 3dots(...) if fonts do not support this UTF-8 character.

Since:
1.13.2
normalLineHeight: number
Default line height value as a number when line-height is normal.

This value is required during max-height calculation for the browsers that do not support line-clamping. It is better to define line-height in CSS instead of "normal" to get consistent maxLines results since normal line-height not only varies from browser to browser but they also vary from one font face to another and can also vary within a given face.

Default value is 1.2

Since:
1.22
Method Detail
sap.m.Text.extend(sClassName, oClassInfo?, FNMetaImpl?): function
Creates a new subclass of class sap.m.Text with name sClassName and enriches it with the information contained in oClassInfo.

oClassInfo might contain the same kind of information as described in sap.ui.core.Control.extend.

Parameters:
{string}sClassName Name of the class being created
{object}oClassInfo? Object literal with information about the class
{function}FNMetaImpl? Constructor function for the metadata object; if not given, it defaults to sap.ui.core.ElementMetadata
Returns:
{function} Created class / constructor function
sap.m.Text.getMetadata(): sap.ui.base.Metadata
Returns a metadata object for class sap.m.Text.
Returns:
{sap.ui.base.Metadata} Metadata object describing this class
sap.m.Text.setNodeValue(oDomRef, sNodeValue?)
To prevent from the layout thrashing of the textContent call, this method first tries to set the nodeValue of the first child if it exists.
Parameters:
{HTMLElement}oDomRef DOM reference of the text node container.
{String}sNodeValue? new Node value.
Since:
1.30.3
bindText(oBindingInfo): sap.m.Text
Binds property text to model data.

See ManagedObject.bindProperty for a detailed description of the possible properties of oBindingInfo

Parameters:
{object}oBindingInfo The binding information
Returns:
{sap.m.Text} Reference to this in order to allow method chaining
clampHeight(oDomRef?): Number
Sets the max-height to support maxLines property.
Parameters:
{HTMLElement}oDomRef? DOM reference of the text container.
Since:
1.22
Returns:
{Number} calculated max height value
clampText(oDomRef?, iStartPos?, iEndPos?): number|undefined
Clamps the wrapping text according to max lines and returns the found ellipsis position.

Parameters can be used for better performance.

Parameters:
{HTMLElement}oDomRef? DOM reference of the text container.
{number}iStartPos? Start point of the ellipsis search.
{number}iEndPos? End point of the ellipsis search.
Since:
1.20
Returns:
{number|undefined} Returns found ellipsis position or undefined
getAccessibilityInfo()
See:
{sap.ui.core.Control#getAccessibilityInfo}
getClampHeight(oDomRef?): Number
Returns the max height according to max lines and line height calculation.

This is not calculated max-height!

Parameters:
{HTMLElement}oDomRef? DOM reference of the text container.
Since:
1.22
Returns:
{Number}
getLineHeight(oDomRef?): Number
Caches and returns the computed line height of the text.
Parameters:
{HTMLElement}oDomRef? DOM reference of the text container.
Since:
1.22
Returns:
{Number} returns calculated line-height
See:
sap.m.Text#cacheLineHeight
getMaxLines(): int
Gets current value of property maxLines.

Limits the number of lines for wrapping texts.

Note: The multi-line overflow indicator depends on the browser line clamping support. For such browsers, this will be shown as ellipsis, for the other browsers the overflow will just be hidden.

Since:
1.13.2
Returns:
{int} Value of property maxLines
getText(): string
Gets current value of property text.

Determines the text to be displayed.

Default value is .

Returns:
{string} Value of property text
getTextAlign(): sap.ui.core.TextAlign
Gets current value of property textAlign.

Sets the horizontal alignment of the text.

Default value is Begin.

Returns:
{sap.ui.core.TextAlign} Value of property textAlign
getTextDirection(): sap.ui.core.TextDirection
Gets current value of property textDirection.

Available options for the text direction are LTR and RTL. By default the control inherits the text direction from its parent control.

Default value is Inherit.

Returns:
{sap.ui.core.TextDirection} Value of property textDirection
getTextDomRef(): HTMLElement|null
Returns the text node container's DOM reference.

This can be different from getDomRef when inner wrapper is needed.

Since:
1.22
Returns:
{HTMLElement|null}
getWidth(): sap.ui.core.CSSSize
Gets current value of property width.

Sets the width of the Text control. By default, the Text control uses the full width available. Set this property to restrict the width to a custom value.

Returns:
{sap.ui.core.CSSSize} Value of property width
getWrapping(): boolean
Gets current value of property wrapping.

Enables text wrapping.

Default value is true.

Returns:
{boolean} Value of property wrapping
hasMaxLines(): HTMLElement|null
Determines whether max lines should be rendered or not.
Since:
1.22
Returns:
{HTMLElement|null}
setMaxLines(iMaxLines): sap.m.Text
Sets a new value for property maxLines.

Limits the number of lines for wrapping texts.

Note: The multi-line overflow indicator depends on the browser line clamping support. For such browsers, this will be shown as ellipsis, for the other browsers the overflow will just be hidden.

When called with a value of null or undefined, the default value of the property will be restored.

Parameters:
{int}iMaxLines New value for property maxLines
Since:
1.13.2
Returns:
{sap.m.Text} Reference to this in order to allow method chaining
setText(sText): sap.m.Text
Sets a new value for property text.

Determines the text to be displayed.

When called with a value of null or undefined, the default value of the property will be restored.

Default value is .

Parameters:
{string}sText New value for property text
Returns:
{sap.m.Text} Reference to this in order to allow method chaining
setTextAlign(sTextAlign): sap.m.Text
Sets a new value for property textAlign.

Sets the horizontal alignment of the text.

When called with a value of null or undefined, the default value of the property will be restored.

Default value is Begin.

Parameters:
{sap.ui.core.TextAlign}sTextAlign New value for property textAlign
Returns:
{sap.m.Text} Reference to this in order to allow method chaining
setTextDirection(sTextDirection): sap.m.Text
Sets a new value for property textDirection.

Available options for the text direction are LTR and RTL. By default the control inherits the text direction from its parent control.

When called with a value of null or undefined, the default value of the property will be restored.

Default value is Inherit.

Parameters:
{sap.ui.core.TextDirection}sTextDirection New value for property textDirection
Returns:
{sap.m.Text} Reference to this in order to allow method chaining
setWidth(sWidth): sap.m.Text
Sets a new value for property width.

Sets the width of the Text control. By default, the Text control uses the full width available. Set this property to restrict the width to a custom value.

When called with a value of null or undefined, the default value of the property will be restored.

Parameters:
{sap.ui.core.CSSSize}sWidth New value for property width
Returns:
{sap.m.Text} Reference to this in order to allow method chaining
setWrapping(bWrapping): sap.m.Text
Sets a new value for property wrapping.

Enables text wrapping.

When called with a value of null or undefined, the default value of the property will be restored.

Default value is true.

Parameters:
{boolean}bWrapping New value for property wrapping
Returns:
{sap.m.Text} Reference to this in order to allow method chaining
unbindText(): sap.m.Text
Unbinds property text from model data.
Returns:
{sap.m.Text} Reference to this in order to allow method chaining