Expand all

abstract OO.ui.mixin.ButtonElement

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:
Name Type Attributes Default Description
$button jQuery optional

The button element created by the class. If this configuration is omitted, the button element will use a generated <a>.

framed boolean optional
true

Render the button with a frame

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:
Cancel mouse down events.

Methods

isActive() → {boolean}protected #

Check if the button is active

Source:

Returns:

The button is active

Type
boolean
Check if the button is active

isFramed() → {boolean} #

Check if button has a frame.

Source:

Returns:

Button is framed

Type
boolean
Check if button has a frame.

onClick(e) → {undefined|boolean}protected #

Handles mouse click events.

Parameters:

Name Type Description
e jQuery.Event

Mouse click event

Source:

Fires:

Returns:

False to prevent default if event is handled

Type
undefined | boolean
Handles mouse click events.

onDocumentKeyUp(e)protected #

Handles document key up events.

Parameters:

Name Type Description
e KeyboardEvent

Key up event

Source:
Handles document key up events.

onDocumentMouseUp(e)protected #

Handles document mouse up events.

Parameters:

Name Type Description
e MouseEvent

Mouse up event

Source:
Handles document mouse up events.

onKeyDown(e)protected #

Handles key down events.

Parameters:

Name Type Description
e jQuery.Event

Key down event

Source:
Handles key down events.

onKeyPress(e) → {undefined|boolean}protected #

Handles key press events.

Parameters:

Name Type Description
e jQuery.Event

Key press event

Source:

Fires:

Returns:

False to prevent default if event is handled

Type
undefined | boolean
Handles key press events.

onMouseDown(e) → {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
Handles mouse down events.

setActive([value]) → {OO.ui.Element}protectedchainable #

Set the button's active state.

The active state can be set on:

Parameters:

Name Type Attributes Default Description
value boolean optional
false

Make button active

Source:

Returns:

The element, for chaining

Type
OO.ui.Element
Set the button's active state.

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:
Set the button element.

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
Render the button with or without a frame.

Events

click() #

A 'click' event is emitted when the button element is clicked.

Source:
A 'click' event is emitted when the button element is clicked.