[qooxdoo-commit] SF.net SVN: qooxdoo:[14765] trunk/qooxdoo/frontend/framework/source/class/ qx/even
Brought to you by:
ecker,
martinwittemann
From: <fj...@us...> - 2008-07-23 15:09:45
|
Revision: 14765 http://qooxdoo.svn.sourceforge.net/qooxdoo/?rev=14765&view=rev Author: fjakobs Date: 2008-07-23 15:09:41 +0000 (Wed, 23 Jul 2008) Log Message: ----------- port some methods from the legacy DomEvent to the 0.8 Dom event class Modified Paths: -------------- trunk/qooxdoo/frontend/framework/source/class/qx/event/type/Dom.js Modified: trunk/qooxdoo/frontend/framework/source/class/qx/event/type/Dom.js =================================================================== --- trunk/qooxdoo/frontend/framework/source/class/qx/event/type/Dom.js 2008-07-23 14:04:24 UTC (rev 14764) +++ trunk/qooxdoo/frontend/framework/source/class/qx/event/type/Dom.js 2008-07-23 15:09:41 UTC (rev 14765) @@ -26,9 +26,58 @@ { extend : qx.event.type.Native, + + + statics : + { + /** {Integer} The modifier mask for the shift key. */ + SHIFT_MASK : 1, + + /** {Integer} The modifier mask for the control key. */ + CTRL_MASK : 2, + + /** {Integer} The modifier mask for the alt key. */ + ALT_MASK : 4, + + /** {Integer} The modifier mask for the meta key (e.g. apple key on Macs). */ + META_MASK : 8 + }, + + members : { /** + * Return in a bit map, which modifier keys are pressed. The constants + * {@link #SHIFT_MASK}, {@link #CTRL_MASK}, {@link #ALT_MASK} and + * {@link #META_MASK} define the bit positions of the corresponding keys. + * + * @return {Integer} A bit map with the pressed modifier keys. + */ + getModifiers : function() + { + if (!this.__modifiers) + { + var mask = 0; + var evt = this._native; + if (evt.shiftKey) { + mask |= qx.event.type.Dom.SHIFT_MASK; + } + if (evt.ctrlKey) { + mask |= qx.event.type.Dom.CTRL_MASK; + } + if (evt.altKey) { + mask |= qx.event.type.Dom.ALT_MASK; + } + if (evt.metaKey) { + mask |= qx.event.type.Dom.META_MASK; + } + return mask; + } + return this.__modifiers; + }, + + + /** * Returns whether the the ctrl key is pressed. * * @type member @@ -69,6 +118,22 @@ */ isMetaPressed : function() { return this._native.metaKey; + }, + + + /** + * Returns whether the ctrl key or (on the Mac) the command key is pressed. + * + * @return {Boolean} <code>true</code> if the command key is pressed on the Mac + * or the ctrl key is pressed on another system. + */ + isCtrlOrCommandPressed : function() + { + if (qx.bom.client.Platform.MAC) { + return this._native.metaKey; + } else { + return this._native.ctrlKey; + } } } }); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |