Class sap.ui.core.IconModule: sap/ui/core/Icon

extends Control

Icon uses embedded font instead of pixel image. Comparing to image, Icon is easily scalable, color can be altered live and various effects can be added using css.

A set of built in Icons is available and they can be fetched by calling sap.ui.core.IconPool.getIconURI and set this value to the src property on the Icon.


Since: 1.11.1.
Constructor Summary
new sap.ui.core.Icon(sId?, mSettings?)Constructor for a new Icon.
Event Summary
press(oControlEvent)This event is fired when icon is pressed/activated by the user.
Events borrowed from class sap.ui.core.Control
Method Summary
sap.ui.core.Icon.extend(sClassName, oClassInfo?, FNMetaImpl?)Creates a new subclass of class sap.ui.core.Icon with name sClassName and enriches it with the information contained in oClassInfo.
sap.ui.core.Icon.getMetadata()Returns a metadata object for class sap.ui.core.Icon.
addAriaLabelledBy(vAriaLabelledBy)Adds some ariaLabelledBy into the association ariaLabelledBy.
attachPress(oData?, fnFunction, oListener?)Attaches event handler fnFunction to the press event of this sap.ui.core.Icon.
detachPress(fnFunction, oListener)Detaches event handler fnFunction from the press event of this sap.ui.core.Icon.
firePress(mArguments?)Fires event press to attached listeners.
getActiveBackgroundColor()Gets current value of property activeBackgroundColor.
getActiveColor()Gets current value of property activeColor.
getAlt()Gets current value of property alt.
getAriaLabelledBy()Returns array of IDs of the elements which are the current targets of the association ariaLabelledBy.
getBackgroundColor()Gets current value of property backgroundColor.
getColor()Gets current value of property color.
getDecorative()Gets current value of property decorative.
getHeight()Gets current value of property height.
getHoverBackgroundColor()Gets current value of property hoverBackgroundColor.
getHoverColor()Gets current value of property hoverColor.
getNoTabStop()Gets current value of property noTabStop.
getSize()Gets current value of property size.
getSrc()Gets current value of property src.
getUseIconTooltip()Gets current value of property useIconTooltip.
getWidth()Gets current value of property width.
removeAllAriaLabelledBy()Removes all the controls in the association named ariaLabelledBy.
removeAriaLabelledBy(vAriaLabelledBy)Removes an ariaLabelledBy from the association named ariaLabelledBy.
setActiveBackgroundColor(sActiveBackgroundColor)Sets a new value for property activeBackgroundColor.
setActiveColor(sActiveColor)Sets a new value for property activeColor.
setAlt(sAlt)Sets a new value for property alt.
setBackgroundColor(sBackgroundColor)Sets a new value for property backgroundColor.
setColor(sColor)Sets a new value for property color.
setDecorative(bDecorative)Sets a new value for property decorative.
setHeight(sHeight)Sets a new value for property height.
setHoverBackgroundColor(sHoverBackgroundColor)Sets a new value for property hoverBackgroundColor.
setHoverColor(sHoverColor)Sets a new value for property hoverColor.
setNoTabStop(bNoTabStop)Sets a new value for property noTabStop.
setSize(sSize)Sets a new value for property size.
setSrc(sSrc)Sets a new value for property src.
setUseIconTooltip(bUseIconTooltip)Sets a new value for property useIconTooltip.
setWidth(sWidth)Sets a new value for property width.
Constructor Detail
new sap.ui.core.Icon(sId?, mSettings?)
Constructor for a new Icon.

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
Event Detail
press(oControlEvent)
This event is fired when icon is pressed/activated by the user. When a handler is attached to this event, the Icon gets tab stop. If you want to disable this behavior, set the noTabStop property to true.
Parameters:
{sap.ui.base.Event}oControlEvent
{sap.ui.base.EventProvider}oControlEvent.getSource
{object}oControlEvent.getParameters
Method Detail
sap.ui.core.Icon.extend(sClassName, oClassInfo?, FNMetaImpl?): function
Creates a new subclass of class sap.ui.core.Icon 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.ui.core.Icon.getMetadata(): sap.ui.base.Metadata
Returns a metadata object for class sap.ui.core.Icon.
Returns:
{sap.ui.base.Metadata} Metadata object describing this class
addAriaLabelledBy(vAriaLabelledBy): sap.ui.core.Icon
Adds some ariaLabelledBy into the association ariaLabelledBy.
Parameters:
{string|sap.ui.core.Control}vAriaLabelledBy the ariaLabelledBy to add; if empty, nothing is inserted
Returns:
{sap.ui.core.Icon} Reference to this in order to allow method chaining
attachPress(oData?, fnFunction, oListener?): sap.ui.core.Icon
Attaches event handler fnFunction to the press event of this sap.ui.core.Icon.

When called, the context of the event handler (its this) will be bound to oListener if specified, otherwise it will be bound to this sap.ui.core.Icon itself.

This event is fired when icon is pressed/activated by the user. When a handler is attached to this event, the Icon gets tab stop. If you want to disable this behavior, set the noTabStop property to true.

Parameters:
{object}oData? An application-specific payload object that will be passed to the event handler along with the event object when firing the event
{function}fnFunction The function to be called when the event occurs
{object}oListener? Context object to call the event handler with. Defaults to this sap.ui.core.Icon itself
Returns:
{sap.ui.core.Icon} Reference to this in order to allow method chaining
detachPress(fnFunction, oListener): sap.ui.core.Icon
Detaches event handler fnFunction from the press event of this sap.ui.core.Icon.

The passed function and listener object must match the ones used for event registration.

Parameters:
{function}fnFunction The function to be called, when the event occurs
{object}oListener Context object on which the given function had to be called
Returns:
{sap.ui.core.Icon} Reference to this in order to allow method chaining
firePress(mArguments?): sap.ui.core.Icon
Fires event press to attached listeners.
Parameters:
{Map}mArguments? The arguments to pass along with the event
Returns:
{sap.ui.core.Icon} Reference to this in order to allow method chaining
getAccessibilityInfo()
See:
{sap.ui.core.Control#getAccessibilityInfo}
getActiveBackgroundColor(): string
Gets current value of property activeBackgroundColor.

Background color for Icon in active state.

Returns:
{string} Value of property activeBackgroundColor
getActiveColor(): string
Gets current value of property activeColor.

This color is shown when icon is pressed/activated by the user.

Returns:
{string} Value of property activeColor
getAlt(): string
Gets current value of property alt.

This defines the alternative text which is used for outputting the aria-label attribute on the DOM.

Since:
1.30.0
Returns:
{string} Value of property alt
getAriaLabelledBy(): sap.ui.core.Control[]
Returns array of IDs of the elements which are the current targets of the association ariaLabelledBy.
Returns:
{sap.ui.core.Control[]}
getBackgroundColor(): string
Gets current value of property backgroundColor.

Background color of the Icon in normal state.

Returns:
{string} Value of property backgroundColor
getColor(): string
Gets current value of property color.

The color of the Icon. If color is not defined here, the Icon inherits the color from its DOM parent.

Returns:
{string} Value of property color
getDecorative(): boolean
Gets current value of property decorative.

A decorative icon is included for design reasons. Accessibility tools will ignore decorative icons. Tab stop isn't affected by this property anymore and it's now controlled by the existence of press event handler and the noTabStop property.

Default value is true.

Since:
1.16.4
Returns:
{boolean} Value of property decorative
getHeight(): sap.ui.core.CSSSize
Gets current value of property height.

This is the height of the DOM element which contains the Icon. Setting this property doesn't affect the size of the font. If you want to make the font bigger, increase the size property.

Returns:
{sap.ui.core.CSSSize} Value of property height
getHoverBackgroundColor(): string
Gets current value of property hoverBackgroundColor.

Background color for Icon in hover state. This property has no visual effect when run on mobile device.

Returns:
{string} Value of property hoverBackgroundColor
getHoverColor(): string
Gets current value of property hoverColor.

This color is shown when icon is hovered. This property has no visual effect when run on mobile device.

Returns:
{string} Value of property hoverColor
getNoTabStop(): boolean
Gets current value of property noTabStop.

Defines whether the tab stop of icon is controlled by the existence of press event handler. When it's set to false, Icon control has tab stop when press event handler is attached. If it's set to true, Icon control never has tab stop no matter whether press event handler exists or not.

Default value is false.

Since:
1.30.1
Returns:
{boolean} Value of property noTabStop
Gets current value of property size.

Since Icon uses font, this property will be applied to the css font-size property on the rendered DOM element.

Returns:
{sap.ui.core.CSSSize} Value of property size
getSrc(): sap.ui.core.URI
Gets current value of property src.

This property should be set by the return value of calling sap.ui.core.IconPool.getIconURI with a Icon name parameter and an optional collection parameter which is required when using application extended Icons. A list of standard FontIcon is available here.

Returns:
{sap.ui.core.URI} Value of property src
getUseIconTooltip(): boolean
Gets current value of property useIconTooltip.

Decides whether a default Icon tooltip should be used if no tooltip is set.

Default value is true.

Since:
1.30.0
Returns:
{boolean} Value of property useIconTooltip
getWidth(): sap.ui.core.CSSSize
Gets current value of property width.

This is the width of the DOM element which contains the Icon. Setting this property doesn't affect the size of the font. If you want to make the font bigger, increase the size property.

Returns:
{sap.ui.core.CSSSize} Value of property width
removeAllAriaLabelledBy(): sap.ui.core.Control[]
Removes all the controls in the association named ariaLabelledBy.
Returns:
{sap.ui.core.Control[]} An array of the removed elements (might be empty)
removeAriaLabelledBy(vAriaLabelledBy): sap.ui.core.Control
Removes an ariaLabelledBy from the association named ariaLabelledBy.
Parameters:
{int|string|sap.ui.core.Control}vAriaLabelledBy The ariaLabelledByto be removed or its index or ID
Returns:
{sap.ui.core.Control} the removed ariaLabelledBy or null
setActiveBackgroundColor(sActiveBackgroundColor): sap.ui.core.Icon
Sets a new value for property activeBackgroundColor.

Background color for Icon in active state.

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

Parameters:
{string}sActiveBackgroundColor New value for property activeBackgroundColor
Returns:
{sap.ui.core.Icon} Reference to this in order to allow method chaining
setActiveColor(sActiveColor): sap.ui.core.Icon
Sets a new value for property activeColor.

This color is shown when icon is pressed/activated by the user.

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

Parameters:
{string}sActiveColor New value for property activeColor
Returns:
{sap.ui.core.Icon} Reference to this in order to allow method chaining
setAlt(sAlt): sap.ui.core.Icon
Sets a new value for property alt.

This defines the alternative text which is used for outputting the aria-label attribute on the DOM.

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

Parameters:
{string}sAlt New value for property alt
Since:
1.30.0
Returns:
{sap.ui.core.Icon} Reference to this in order to allow method chaining
setBackgroundColor(sBackgroundColor): sap.ui.core.Icon
Sets a new value for property backgroundColor.

Background color of the Icon in normal state.

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

Parameters:
{string}sBackgroundColor New value for property backgroundColor
Returns:
{sap.ui.core.Icon} Reference to this in order to allow method chaining
setColor(sColor): sap.ui.core.Icon
Sets a new value for property color.

The color of the Icon. If color is not defined here, the Icon inherits the color from its DOM parent.

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

Parameters:
{string}sColor New value for property color
Returns:
{sap.ui.core.Icon} Reference to this in order to allow method chaining
setDecorative(bDecorative): sap.ui.core.Icon
Sets a new value for property decorative.

A decorative icon is included for design reasons. Accessibility tools will ignore decorative icons. Tab stop isn't affected by this property anymore and it's now controlled by the existence of press event handler and the noTabStop property.

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

Default value is true.

Parameters:
{boolean}bDecorative New value for property decorative
Since:
1.16.4
Returns:
{sap.ui.core.Icon} Reference to this in order to allow method chaining
setHeight(sHeight): sap.ui.core.Icon
Sets a new value for property height.

This is the height of the DOM element which contains the Icon. Setting this property doesn't affect the size of the font. If you want to make the font bigger, increase the size property.

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

Parameters:
{sap.ui.core.CSSSize}sHeight New value for property height
Returns:
{sap.ui.core.Icon} Reference to this in order to allow method chaining
setHoverBackgroundColor(sHoverBackgroundColor): sap.ui.core.Icon
Sets a new value for property hoverBackgroundColor.

Background color for Icon in hover state. This property has no visual effect when run on mobile device.

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

Parameters:
{string}sHoverBackgroundColor New value for property hoverBackgroundColor
Returns:
{sap.ui.core.Icon} Reference to this in order to allow method chaining
setHoverColor(sHoverColor): sap.ui.core.Icon
Sets a new value for property hoverColor.

This color is shown when icon is hovered. This property has no visual effect when run on mobile device.

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

Parameters:
{string}sHoverColor New value for property hoverColor
Returns:
{sap.ui.core.Icon} Reference to this in order to allow method chaining
setNoTabStop(bNoTabStop): sap.ui.core.Icon
Sets a new value for property noTabStop.

Defines whether the tab stop of icon is controlled by the existence of press event handler. When it's set to false, Icon control has tab stop when press event handler is attached. If it's set to true, Icon control never has tab stop no matter whether press event handler exists or not.

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

Default value is false.

Parameters:
{boolean}bNoTabStop New value for property noTabStop
Since:
1.30.1
Returns:
{sap.ui.core.Icon} Reference to this in order to allow method chaining
setSize(sSize): sap.ui.core.Icon
Sets a new value for property size.

Since Icon uses font, this property will be applied to the css font-size property on the rendered DOM element.

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

Parameters:
{sap.ui.core.CSSSize}sSize New value for property size
Returns:
{sap.ui.core.Icon} Reference to this in order to allow method chaining
setSrc(sSrc): sap.ui.core.Icon
Sets a new value for property src.

This property should be set by the return value of calling sap.ui.core.IconPool.getIconURI with a Icon name parameter and an optional collection parameter which is required when using application extended Icons. A list of standard FontIcon is available here.

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

Parameters:
{sap.ui.core.URI}sSrc New value for property src
Returns:
{sap.ui.core.Icon} Reference to this in order to allow method chaining
setUseIconTooltip(bUseIconTooltip): sap.ui.core.Icon
Sets a new value for property useIconTooltip.

Decides whether a default Icon tooltip should be used if no tooltip is set.

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

Default value is true.

Parameters:
{boolean}bUseIconTooltip New value for property useIconTooltip
Since:
1.30.0
Returns:
{sap.ui.core.Icon} Reference to this in order to allow method chaining
setWidth(sWidth): sap.ui.core.Icon
Sets a new value for property width.

This is the width of the DOM element which contains the Icon. Setting this property doesn't affect the size of the font. If you want to make the font bigger, increase the size property.

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.ui.core.Icon} Reference to this in order to allow method chaining