js/foundation/eventmanager/eventmanager.js in rsence-2.0.0.11 vs js/foundation/eventmanager/eventmanager.js in rsence-2.0.1.12
- old
+ new
@@ -35,16 +35,16 @@
*
* The format is an array with an index per "interesting" event value.
*
* = Indexes
* +EVENT.status[ EVENT.button1 ]+:: The state of the left mouse button.
- * 0 when not pressed
- * 1 when pressed.
+ * false when not pressed
+ * true when pressed.
*
* +EVENT.status[ EVENT.button2 ]+:: The state of the right mouse button.
- * 0 when not pressed
- * 1 when pressed.
+ * false when not pressed
+ * true when pressed.
*
* +EVENT.status[ EVENT.crsrX ]+:: The x-coordinate of the mouse cursor.
*
* +EVENT.status[ EVENT.crsrY ]+:: The y-coordinate of the mouse cursor.
*
@@ -60,12 +60,18 @@
* modifier key being held down.
*
* +EVENT.status[ EVENT.shiftKeyDown ]+:: The boolean status of the Shift
* modifier key being held down.
*
+ * +EVENT.status[ EVENT.metaKeyDown ]+:: The boolean status of the Meta
+ * modifier key being held down.
+ *
+ * +EVENT.status[ EVENT.cmdKeyDown ]+:: The boolean status of any of the system-specific
+ * Command, Menu or Start modifier keys being held down.
+ *
**/
- status: [false, false, 0, 0, [], false, false, false],
+ status: [false, false, 0, 0, [], false, false, false, false, false],
/** The index in the status array for the left mouse button.
**/
button1: 0,
@@ -86,22 +92,30 @@
* comes first, last pressed last).
*
**/
keysDown: 4,
-/** The index in the status orray for the state of the Alt modifier key.
+/** The index in the status array for the state of the Alt modifier key.
**/
altKeyDown: 5,
-/** The index in the status orray for the state of the Ctrl modifier key.
+/** The index in the status array for the state of the Ctrl modifier key.
**/
ctrlKeyDown: 6,
-/** The index in the status orray for the state of the Shift modifier key.
+/** The index in the status array for the state of the Shift modifier key.
**/
shiftKeyDown: 7,
+/** The index in the status array for the state of the Meta modifier key.
+ **/
+ metaKeyDown: 8,
+
+/** The index in the status array for the state of the Command modifier key.
+ **/
+ cmdKeyDown: 9,
+
/** A flag to disable, if your applications don't need drop events.
* Setting this to false when not needed improves overall performance,
* because the drop events need constant calculation of the mouse cursor
* location against all possible drop targets.
*
@@ -229,15 +243,27 @@
if (_focusOptions.textEnter) {
if (_this.textEnterCtrls.indexOf(_ctrl.viewId) === -1) {
_this.textEnterCtrls.push(_ctrl.viewId);
}
}
+ else {
+ var _textEnterIndex = _this.textEnterCtrls.indexOf(_ctrl.viewId);
+ if (_textEnterIndex !== -1) {
+ _this.textEnterCtrls.splice(_textEnterIndex,1);
+ }
+ }
if (_focusOptions.resize) {
if (_this.resizeListeners.indexOf(_ctrl.viewId) === -1) {
_this.resizeListeners.push(_ctrl.viewId);
}
}
+ else {
+ var _resizeIndex = _this.resizeListeners.indexOf(_ctrl.viewId);
+ if (_resizeIndex !== -1) {
+ _this.resizeListeners.splice(_resizeIndex,1);
+ }
+ }
Event.observe(_elem, 'mouseover', _this._mouseOver);
},
/** Unregisters the _ctrl object event listeners
**/
@@ -522,16 +548,16 @@
*
* = Parameters
* +_ctrl+:: An object that uses the HControl API, becomes new drag target.
*
**/
- startDragging: function(_ctrl) {
+ startDragging: function(_ctrl, _isLeftButton) {
var _this = EVENT;
_this.dragItems = [_ctrl.elemId];
_this.focus(_ctrl);
_this.changeActiveControl(_ctrl);
- _ctrl.startDrag(_this.status[_this.crsrX], _this.status[_this.crsrY]);
+ _ctrl.startDrag( _this.status[_this.crsrX], _this.status[_this.crsrY], _isLeftButton );
},
/** Mid-level mouse button press manager.
* Gets called on the onMouseDown event.
* Delegates the following calls to the high-level event receivers of all
@@ -586,11 +612,11 @@
_this.changeActiveControl(_newActiveControl);
}
// Call the mouseDown and startDrag events after the active control change has been handled.
for (i = 0; i !== _startDragElementIds.length; i++) {
_this.dragItems.push(_startDragElementIds[i]);
- _this.focusOptions[_startDragElementIds[i]].ctrl.startDrag(x, y);
+ _this.focusOptions[_startDragElementIds[i]].ctrl.startDrag(x, y, _isLeftButton);
_didStartDrag = true;
}
var _stopEvent = _mouseDownElementIds.length;
for (i = 0; i !== _mouseDownElementIds.length; i++) {
@@ -670,10 +696,16 @@
if ((_stopEvent === 0) && (_this.hovered.length !== 0) && (_newActiveControl && (_newActiveControl.textElemId === false))) {
Event.stop(e);
}
}
//if(_this.hovered.length!==0){Event.stop(e);}
+ if(_isLeftButton){
+ _this.status[_this.button1] = false;
+ }
+ else {
+ _this.status[_this.button2] = false;
+ }
return true;
},
/** Changes active ctrl.
* The previous active ctrl gets the _lostActiveStatus pseudo-event,
@@ -720,17 +752,15 @@
y = _this.status[_this.crsrY],
_elemId,
_ctrl,
i = 0;
_this._modifiers(e);
- _this.status[_this.button1] = false;
- _this.status[_this.button2] = false;
// Send endDrag for the currently dragged items even when they don't have focus, and clear the drag item array.
for (; i !== _this.dragItems.length; i++) {
_elemId = _this.dragItems[i];
_ctrl = _this.focusOptions[_elemId].ctrl;
- _ctrl.endDrag(x, y);
+ _ctrl.endDrag(x, y,_isLeftButton);
_didEndDrag = true;
// If the mouse slipped off the dragged item before the mouse button was released, blur the item manually
if (_this.enableDroppableChecks) {
_this._updateHoverItems();
if (_this.hovered.indexOf(_elemId) === -1) {
@@ -756,10 +786,16 @@
if (_this.focusOptions[i].mouseUp === true) {
_this.focusOptions[i].ctrl.mouseUp(x, y, _isLeftButton);
}
}
}
+ if(_isLeftButton){
+ _this.status[_this.button1] = false;
+ }
+ else {
+ _this.status[_this.button2] = false;
+ }
return true;
},
/** Mid-level key press manager.
@@ -769,10 +805,13 @@
**/
keyDown: function(e) {
var _this = EVENT,
_theKeyCode = e.keyCode;
_this._modifiers(e);
+ if(!_this.status[_this.cmdKeyDown] && _this._detectCmdKey(e.keyCode)){
+ _this.status[_this.cmdKeyDown] = true;
+ }
if (_this.activeControl && _this.focusOptions[_this.activeControl.elemId].keyDown === true) {
Event.stop(e);
// Workaround for msie rapid fire keydown
if (_this._lastKeyDown !== _theKeyCode) {
_this.activeControl.keyDown(_theKeyCode);
@@ -810,10 +849,13 @@
_ctrl = HSystem.views[_ctrlId];
if (_ctrl.textEnter) {
_ctrl.textEnter();
}
}
+ if(_this.status[_this.cmdKeyDown] && _this._detectCmdKey(e.keyCode)){
+ _this.status[_this.cmdKeyDown] = false;
+ }
// Remove the key from the realtime array, inserted in keyDown
_keyCodeIndex = _this.status[_this.keysDown].indexOf(_theKeyCode);
if (_keyCodeIndex !== -1) {
_this.status[_this.keysDown].splice(_keyCodeIndex, 1);
}
@@ -855,25 +897,47 @@
_this.focusOptions[i].ctrl.mouseWheel(_delta);
}
}
}
},
-
+
/* Alternative right button detection, wrapper for the mouseDown method */
contextMenu: function(e) {
EVENT.mouseDown(e, false);
Event.stop(e);
+ if(Event.isLeftClick(e)){
+ EVENT.status[EVENT.button2] = false;
+ }
},
-
+
+ _cmdKeys: [
+ 224, // Mozilla Left or Right Command Key
+ 219, // Opera Left Windows Key
+ 220, // Opera Right Windows Key
+ 0, // Opera Menu Key or Linux Gecko: any Windows Key
+ 17, // Opera
+ 91, // Others (Left Start Key or Left Command Key)
+ 92, // Others (Right Start Key)
+ 93 // Others (Menu Key or Right Command Key)
+ ],
+ _detectCmdKey: function( _keyCode ) {
+ return (EVENT._cmdKeys.indexOf(_keyCode) !== -1);
+ },
+
/* Handle the event modifiers. */
_modifiers: function(e) {
var _this = EVENT;
_this.status[_this.altKeyDown] = e.altKey;
_this.status[_this.ctrlKeyDown] = e.ctrlKey;
_this.status[_this.shiftKeyDown] = e.shiftKey;
+ _this.status[_this.metaKeyDown] = e.metaKey;
}
};
+
+var//RSence.Foundation
+EventManager = EVENT;
+
/** Starts the only instance
*/
LOAD(
function() {