Constructor
new OO.ui.mixin.ButtonElement([config])abstract
#
ButtonElement is often mixed into other classes to generate a button, which is a clickable interface element that can be configured with access keys for keyboard interaction. See the OOUI documentation on MediaWiki for examples.
Parameters:
Name | Type | Attributes | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
config |
Object |
optional |
Configuration options Properties:
|
- Source:
ButtonElement is often mixed into other classes to generate a button, which is a clickable interface element that can be configured with access keys for keyboard interaction.
Properties
cancelButtonMouseDownEventsstatic
#
Cancel mouse down events.
This property is usually set to true
to prevent the focus from changing when the button is
clicked.
Classes such as DraggableElement
and
ButtonOptionWidget
use a value of false
so that dragging
behavior is possible and mousedown events can be handled by a parent widget.
Properties:
Type | Description |
---|---|
boolean |
- Source:
Methods
isActive() → {boolean}protected
#
Check if the button is active
- Source:
Returns:
The button is active
- Type
- boolean
isFramed() → {boolean}
#
Check if button has a frame.
- Source:
Returns:
Button is framed
- Type
- boolean
onClick(e) → {undefined
|boolean}protected
#
undefined
|boolean}protected
#
Handles mouse click events.
Parameters:
Name | Type | Description |
---|---|---|
e |
jQuery.Event | Mouse click event |
- Source:
Returns:
False to prevent default if event is handled
- Type
-
undefined
| boolean
Fires:
onDocumentKeyUp(e)protected
#
Handles document key up events.
Parameters:
Name | Type | Description |
---|---|---|
e |
KeyboardEvent | Key up event |
- Source:
onDocumentMouseUp(e)protected
#
Handles document mouse up events.
Parameters:
Name | Type | Description |
---|---|---|
e |
MouseEvent | Mouse up event |
- Source:
onKeyDown(e)protected
#
onKeyPress(e) → {undefined
|boolean}protected
#
undefined
|boolean}protected
#
Handles key press events.
Parameters:
Name | Type | Description |
---|---|---|
e |
jQuery.Event | Key press event |
- Source:
Returns:
False to prevent default if event is handled
- Type
-
undefined
| boolean
Fires:
onMouseDown(e) → {undefined
|boolean}protected
#
undefined
|boolean}protected
#
Handles mouse down events.
Parameters:
Name | Type | Description |
---|---|---|
e |
jQuery.Event | Mouse down event |
- Source:
Returns:
False to prevent default if event is handled
- Type
-
undefined
| boolean
setActive([value]) → {OO.ui.Element}protectedchainable
#
Set the button's active state.
The active state can be set on:
ButtonOptionWidget
when it is selectedToggleButtonWidget
when it is toggle onButtonWidget
when clicking the button would only refresh the page
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
value |
boolean |
optional |
false | Make button active |
- Source:
Returns:
The element, for chaining
- Type
- OO.ui.Element
setButtonElement($button)
#
Set the button element.
This method is used to retarget a button mixin so that its functionality applies to the specified button element instead of the one created by the class. If a button element is already set, the method will remove the mixin’s effect on that element.
Parameters:
Name | Type | Description |
---|---|---|
$button |
jQuery | Element to use as button |
- Source:
toggleFramed([framed]) → {OO.ui.Element}chainable
#
Render the button with or without a frame. Omit the framed
parameter to toggle the button frame
on and off.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
framed |
boolean |
optional |
Make button framed, omit to toggle |
- Source:
Returns:
The element, for chaining
- Type
- OO.ui.Element
Events
click()
#
A 'click' event is emitted when the button element is clicked.
- Source: