define('application/widgets/pointerfocusablebutton', [
'rofl/widgets/pointerfocusablebutton',
'rofl/lib/utils',
'rofl/devices/input/pointer',
'application/events/mousefocusevent',
'application/decorators/buttonpress'
], function (
Base,
Utils,
PointerManager,
MouseFocusEvent,
ButtonPressDecorator
) {
'use strict';
var pointerManager;
return Base.extend({
/**
* Handles the mouse over event.
*/
mouseOverHandler: function mouseOverHandlerFn () {
if (pointerManager.pointerIsOn() && this._pointerSupport) {
if (!this.isFocussed() && !this.preventMouseFocus) {
this.focus();
this.parentWidget.setActiveChildWidget(this);
this.bubbleEvent(new MouseFocusEvent(this));
}
}
},
/**
* Enable/disable pointer support for this button.
*
* @param {boolean} support - Supported or not.
*/
setPointerSupport: function setPointerSupport (support) {
this._pointerSupport = support;
this.setDisabled(!support);
},
/**
* Initializes the button.
*
* @param {string} id - Button id.
* @param {boolean} animationEnabled - Animations enabled or not.
*/
init: function initFn (id, animationEnabled) {
if (!pointerManager) {
pointerManager = PointerManager.getInstance();
}
this._pointerSupport = true;
initFn.base.call(this, id, animationEnabled);
this.decorate([ButtonPressDecorator]);
},
/**
* Select function.
*/
select: function select () {
select.base.call(this);
this._onButtonPress();
},
/**
* OnClick event.
*
* @param {Object} e - The event.
* @private
*/
_onClickEvent: function onClickEvent (e) {
onClickEvent.base.call(this, e);
this._onButtonPress();
}
});
});