Class sap.m.ButtonModule: sap/m/Button
Enables users to trigger actions. For the button UI, you can define some text or an icon, or both.
Constructor Summary
new sap.m.Button(sId?, mSettings?)Constructor for a new Button. Event Summary
press(oControlEvent)Event is fired when the user clicks on the control. tap(oControlEvent)Event is fired when the user taps the control. Method Summary
sap.m.Button.extend(sClassName, oClassInfo?, FNMetaImpl?)Creates a new subclass of class sap.m.Button with name sClassName
and enriches it with the information contained in oClassInfo
. addAriaDescribedBy(vAriaDescribedBy)Adds some ariaDescribedBy into the association ariaDescribedBy
. addAriaLabelledBy(vAriaLabelledBy)Adds some ariaLabelledBy into the association ariaLabelledBy
. attachPress(oData?, fnFunction, oListener?)Attaches event handler fnFunction
to the press
event of this sap.m.Button
. detachPress(fnFunction, oListener)Detaches event handler fnFunction
from the press
event of this sap.m.Button
. firePress(mArguments?)Fires event press
to attached listeners. getAriaDescribedBy()Returns array of IDs of the elements which are the current targets of the association ariaDescribedBy
. getAriaLabelledBy()Returns array of IDs of the elements which are the current targets of the association ariaLabelledBy
. getEnabled()Gets current value of property enabled
. getIcon()Gets current value of property icon
. getText()Gets current value of property text
. getType()Gets current value of property type
. getWidth()Gets current value of property width
. removeAriaDescribedBy(vAriaDescribedBy)Removes an ariaDescribedBy from the association named ariaDescribedBy
. removeAriaLabelledBy(vAriaLabelledBy)Removes an ariaLabelledBy from the association named ariaLabelledBy
. setActiveIcon(sActiveIcon)Sets a new value for property activeIcon
. setEnabled(bEnabled)Sets a new value for property enabled
. setIcon(sIcon)Property setter for the icon setIconFirst(bIconFirst)Sets a new value for property iconFirst
. setText(sText)Property setter for the text setType(sType)Sets a new value for property type
. setWidth(sWidth)Sets a new value for property width
. attachTap(oData?, fnFunction, oListener?)Attaches event handler fnFunction
to the tap
event of this sap.m.Button
. detachTap(fnFunction, oListener)Detaches event handler fnFunction
from the tap
event of this sap.m.Button
. fireTap(mArguments?)Fires event tap
to attached listeners. addStyleClass,
allowTextSelection,
attachBrowserEvent,
attachValidateFieldGroup,
checkFieldGroupIds,
clone,
detachBrowserEvent,
detachValidateFieldGroup,
fireValidateFieldGroup,
getBusy,
getBusyIndicatorDelay,
getControlsByFieldGroupId,
getFieldGroupIds,
getIdForLabel,
getRenderer,
getVisible,
hasStyleClass,
invalidate,
isBusy,
onAfterRendering,
onBeforeRendering,
placeAt,
removeStyleClass,
rerender,
setBusy,
setBusyIndicatorDelay,
setFieldGroupIds,
setVisible,
toggleStyleClass,
triggerValidateFieldGroup $,
addCustomData,
addDependent,
addEventDelegate,
applyFocusInfo,
bindElement,
data,
destroy,
destroyCustomData,
destroyDependents,
destroyLayoutData,
destroyTooltip,
enhanceAccessibilityState,
findElements,
fireEvent,
focus,
getCustomData,
getDependents,
getDomRef,
getElementBinding,
getFocusDomRef,
getFocusInfo,
getInterface,
getLayoutData,
getMetadata,
getTooltip,
getTooltip_AsString,
getTooltip_Text,
indexOfCustomData,
indexOfDependent,
init,
insertCustomData,
insertDependent,
prop,
removeAllCustomData,
removeAllDependents,
removeCustomData,
removeDependent,
removeEventDelegate,
setLayoutData,
setTooltip,
toString,
unbindElement addAggregation,
addAssociation,
applySettings,
attachFormatError,
attachModelContextChange,
attachParseError,
attachValidationError,
attachValidationSuccess,
bindAggregation,
bindContext,
bindObject,
bindProperty,
destroyAggregation,
detachFormatError,
detachModelContextChange,
detachParseError,
detachValidationError,
detachValidationSuccess,
findAggregatedObjects,
fireFormatError,
fireModelContextChange,
fireParseError,
fireValidationError,
fireValidationSuccess,
getAggregation,
getAssociation,
getBinding,
getBindingContext,
getBindingInfo,
getBindingPath,
getEventingParent,
getId,
getModel,
getObjectBinding,
getOriginInfo,
getParent,
getProperty,
hasModel,
indexOfAggregation,
insertAggregation,
isBound,
isInvalidateSuppressed,
isTreeBinding,
propagateMessages,
removeAggregation,
removeAllAggregation,
removeAllAssociation,
removeAssociation,
setAggregation,
setAssociation,
setBindingContext,
setModel,
setProperty,
unbindAggregation,
unbindContext,
unbindObject,
unbindProperty,
validateAggregation,
validateProperty Constructor Detail
new sap.m.Button(sId?, mSettings?)
Constructor for a new Button.
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:
- Properties
- Events
- tap : fnListenerFunction or [fnListenerFunction, oListenerObject] or [oData, fnListenerFunction, oListenerObject]
- press : fnListenerFunction or [fnListenerFunction, oListenerObject] or [oData, fnListenerFunction, oListenerObject]
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)
Event is fired when the user clicks on the control.
Parameters:
tap(oControlEvent)
Event is fired when the user taps the control.
Parameters:
- Deprecated:
- Since version 1.20.0. This event is deprecated, use the press event instead.
Method Detail
sap.m.Button.extend(sClassName, oClassInfo?, FNMetaImpl?): function
Creates a new subclass of class sap.m.Button 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 |
Returns a metadata object for class sap.m.Button.
Returns:
Adds some ariaDescribedBy into the association ariaDescribedBy
.
Parameters:
{string|sap.ui.core.Control} | vAriaDescribedBy | the ariaDescribedBy to add; if empty, nothing is inserted |
Returns:
{sap.m.Button} | Reference to this in order to allow method chaining |
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.m.Button} | Reference to this in order to allow method chaining |
Attaches event handler
fnFunction
to the
press
event of this
sap.m.Button
.
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.m.Button
itself.
Event is fired when the user clicks on the control.
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.m.Button itself |
Returns:
{sap.m.Button} | Reference to this in order to allow method chaining |
Detaches event handler
fnFunction
from the
press
event of this
sap.m.Button
.
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.m.Button} | Reference to this in order to allow method chaining |
Fires event press
to attached listeners.
Parameters:
{Map} | mArguments? | The arguments to pass along with the event |
Returns:
{sap.m.Button} | Reference to this in order to allow method chaining |
getAccessibilityInfo()
See:
{sap.ui.core.Control#getAccessibilityInfo} |
Gets current value of property
activeIcon
.
The source property of an alternative icon for the active (depressed) state of the button. Both active and default icon properties should be defined and have the same type: image or icon font. If the icon
property is not set or has a different type, the active icon is not displayed.
Returns:
Returns array of IDs of the elements which are the current targets of the association ariaDescribedBy
.
Returns:
Returns array of IDs of the elements which are the current targets of the association ariaLabelledBy
.
Returns:
getEnabled(): boolean
Gets current value of property
enabled
.
Boolean property to enable the control (default is true). Buttons that are disabled have other colors than enabled ones, depending on custom settings
Default value is true
.
Returns:
{boolean} | Value of property enabled |
Gets current value of property
icon
.
Icon to be displayed as graphical element within the button. This can be an image or an icon from the icon font.
Returns:
getIconDensityAware(): boolean
Gets current value of property
iconDensityAware
.
By default, this is set to true but then one or more requests are sent trying to get the density perfect version of image if this version of image doesn't exist on the server.
If only one version of image is provided, set this value to false to avoid the attempt of fetching density perfect image.
Default value is true
.
Returns:
{boolean} | Value of property iconDensityAware |
getIconFirst(): boolean
Gets current value of property
iconFirst
.
If set to true (default), the display sequence is 1. icon 2. control text
Default value is true
.
Returns:
{boolean} | Value of property iconFirst |
getPopupAnchorDomRef(): DomNode
Defines to which DOM reference the Popup should be docked
Returns:
{DomNode} | the DOM reference that Popup should dock to |
getText(): string
Gets current value of property
text
.
Button text
Returns:
{string} | Value of property text |
Gets current value of property
textDirection
.
This property specifies the element's text directionality with enumerated options. By default, the control inherits text direction from the DOM.
Default value is Inherit
.
- Since:
- 1.28.0
Returns:
Gets current value of property
type
.
Type of a button (e.g. Default, Accept, Reject, Back, etc.)
Default value is Default
.
Returns:
Gets current value of property
width
.
Defines the width of the button.
Returns:
Removes all the controls in the association named ariaDescribedBy
.
Returns:
Removes all the controls in the association named ariaLabelledBy
.
Returns:
Removes an ariaDescribedBy from the association named ariaDescribedBy
.
Parameters:
{int|string|sap.ui.core.Control} | vAriaDescribedBy | The ariaDescribedByto be removed or its index or ID |
Returns:
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:
Sets a new value for property
activeIcon
.
The source property of an alternative icon for the active (depressed) state of the button. Both active and default icon properties should be defined and have the same type: image or icon font. If the icon
property is not set or has a different type, the active icon is not displayed.
When called with a value of null
or undefined
, the default value of the property will be restored.
Parameters:
Returns:
{sap.m.Button} | Reference to this in order to allow method chaining |
Sets a new value for property
enabled
.
Boolean property to enable the control (default is true). Buttons that are disabled have other colors than enabled ones, depending on custom settings
When called with a value of null
or undefined
, the default value of the property will be restored.
Default value is true
.
Parameters:
{boolean} | bEnabled | New value for property enabled |
Returns:
{sap.m.Button} | Reference to this in order to allow method chaining |
Property setter for the icon
Parameters:
Returns:
Sets a new value for property
iconDensityAware
.
By default, this is set to true but then one or more requests are sent trying to get the density perfect version of image if this version of image doesn't exist on the server.
If only one version of image is provided, set this value to false to avoid the attempt of fetching density perfect image.
When called with a value of null
or undefined
, the default value of the property will be restored.
Default value is true
.
Parameters:
{boolean} | bIconDensityAware | New value for property iconDensityAware |
Returns:
{sap.m.Button} | Reference to this in order to allow method chaining |
Sets a new value for property
iconFirst
.
If set to true (default), the display sequence is 1. icon 2. control text
When called with a value of null
or undefined
, the default value of the property will be restored.
Default value is true
.
Parameters:
{boolean} | bIconFirst | New value for property iconFirst |
Returns:
{sap.m.Button} | Reference to this in order to allow method chaining |
Property setter for the text
Parameters:
{string} | sText | new value of the Text attribute |
Returns:
Sets a new value for property
textDirection
.
This property specifies the element's text directionality with enumerated options. By default, the control inherits text direction from the DOM.
When called with a value of null
or undefined
, the default value of the property will be restored.
Default value is Inherit
.
Parameters:
- Since:
- 1.28.0
Returns:
{sap.m.Button} | Reference to this in order to allow method chaining |
Sets a new value for property
type
.
Type of a button (e.g. Default, Accept, Reject, Back, etc.)
When called with a value of null
or undefined
, the default value of the property will be restored.
Default value is Default
.
Parameters:
Returns:
{sap.m.Button} | Reference to this in order to allow method chaining |
Sets a new value for property
width
.
Defines the width of the button.
When called with a value of null
or undefined
, the default value of the property will be restored.
Parameters:
Returns:
{sap.m.Button} | Reference to this in order to allow method chaining |
Attaches event handler
fnFunction
to the
tap
event of this
sap.m.Button
.
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.m.Button
itself.
Event is fired when the user taps the control.
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.m.Button itself |
- Deprecated:
- Since version 1.20.0. This event is deprecated, use the press event instead.
Returns:
{sap.m.Button} | Reference to this in order to allow method chaining |
Detaches event handler
fnFunction
from the
tap
event of this
sap.m.Button
.
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 |
- Deprecated:
- Since version 1.20.0. This event is deprecated, use the press event instead.
Returns:
{sap.m.Button} | Reference to this in order to allow method chaining |
Fires event tap
to attached listeners.
Parameters:
{Map} | mArguments? | The arguments to pass along with the event |
- Deprecated:
- Since version 1.20.0. This event is deprecated, use the press event instead.
Returns:
{sap.m.Button} | Reference to this in order to allow method chaining |