[qooxdoo-commit] SF.net SVN: qooxdoo:[14747] trunk/qooxdoo/frontend/framework/source/class/ qx/ui/m
Brought to you by:
ecker,
martinwittemann
From: <wp...@us...> - 2008-07-23 12:33:36
|
Revision: 14747 http://qooxdoo.svn.sourceforge.net/qooxdoo/?rev=14747&view=rev Author: wpbasti Date: 2008-07-23 12:33:32 +0000 (Wed, 23 Jul 2008) Log Message: ----------- Improved key event support of menu system. Added blocks for keyup/keydown when a menu is opened. Modified Paths: -------------- trunk/qooxdoo/frontend/framework/source/class/qx/ui/menu/AbstractButton.js trunk/qooxdoo/frontend/framework/source/class/qx/ui/menu/Button.js trunk/qooxdoo/frontend/framework/source/class/qx/ui/menu/CheckBox.js trunk/qooxdoo/frontend/framework/source/class/qx/ui/menu/Manager.js trunk/qooxdoo/frontend/framework/source/class/qx/ui/menu/Menu.js trunk/qooxdoo/frontend/framework/source/class/qx/ui/menu/RadioButton.js Modified: trunk/qooxdoo/frontend/framework/source/class/qx/ui/menu/AbstractButton.js =================================================================== --- trunk/qooxdoo/frontend/framework/source/class/qx/ui/menu/AbstractButton.js 2008-07-23 12:07:44 UTC (rev 14746) +++ trunk/qooxdoo/frontend/framework/source/class/qx/ui/menu/AbstractButton.js 2008-07-23 12:33:32 UTC (rev 14747) @@ -42,8 +42,9 @@ // Use hard coded layout this._setLayout(new qx.ui.layout.MenuButton); - // Add mouse listeners + // Add listeners this.addListener("mouseup", this._onMouseUp); + this.addListener("keypress", this._onKeyPress); }, @@ -198,15 +199,24 @@ /** * Event listener for mouseup event * - * @param e {qx.event.type.Mouse} Mouse event + * @param e {qx.event.type.Mouse} mouseup event */ _onMouseUp : function(e) { // pass }, + /** + * Event listener for mouseup event + * + * @param e {qx.event.type.KeySequence} keypress event + */ + _onKeyPress : function(e) { + // pass + }, + /* --------------------------------------------------------------------------- PROPERTY APPLY ROUTINES Modified: trunk/qooxdoo/frontend/framework/source/class/qx/ui/menu/Button.js =================================================================== --- trunk/qooxdoo/frontend/framework/source/class/qx/ui/menu/Button.js 2008-07-23 12:07:44 UTC (rev 14746) +++ trunk/qooxdoo/frontend/framework/source/class/qx/ui/menu/Button.js 2008-07-23 12:33:32 UTC (rev 14747) @@ -110,6 +110,12 @@ // overridden _onMouseUp : function(e) { this.execute(); + }, + + + // overridden + _onKeyPress : function(e) { + this.execute(); } } }); Modified: trunk/qooxdoo/frontend/framework/source/class/qx/ui/menu/CheckBox.js =================================================================== --- trunk/qooxdoo/frontend/framework/source/class/qx/ui/menu/CheckBox.js 2008-07-23 12:07:44 UTC (rev 14746) +++ trunk/qooxdoo/frontend/framework/source/class/qx/ui/menu/CheckBox.js 2008-07-23 12:33:32 UTC (rev 14747) @@ -111,6 +111,12 @@ // overridden _onMouseUp : function(e) { this.toggleChecked(); + }, + + + // overridden + _onKeyPress : function(e) { + this.toggleChecked(); } } }); Modified: trunk/qooxdoo/frontend/framework/source/class/qx/ui/menu/Manager.js =================================================================== --- trunk/qooxdoo/frontend/framework/source/class/qx/ui/menu/Manager.js 2008-07-23 12:07:44 UTC (rev 14746) +++ trunk/qooxdoo/frontend/framework/source/class/qx/ui/menu/Manager.js 2008-07-23 12:33:32 UTC (rev 14747) @@ -53,6 +53,8 @@ root.addListener("mouseup", this._onMouseUp, this); // React on keypress events + root.addListener("keydown", this._onKeyDown, this, true); + root.addListener("keyup", this._onKeyUp, this, true); root.addListener("keypress", this._onKeyPress, this, true); // Hide all when the window is blurred @@ -424,7 +426,37 @@ */ /** - * Event handler for all key events. Delegates the event to the more + * Event handler for all keydown events. Stops all events + * when any menu is opened. + * + * @param e {qx.event.type.KeySequence} Keyboard event + * @return {void} + */ + _onKeyDown : function(e) + { + if (this.getActiveMenu()) { + e.stop(); + } + }, + + + /** + * Event handler for all keyup events. Stops all events + * when any menu is opened. + * + * @param e {qx.event.type.KeySequence} Keyboard event + * @return {void} + */ + _onKeyUp : function(e) + { + if (this.getActiveMenu()) { + e.stop(); + } + }, + + + /** + * Event handler for all keypress events. Delegates the event to the more * specific methods defined in this class. * * Currently processes the keys: <code>Up</code>, <code>Down</code>, @@ -459,7 +491,7 @@ break; case "Enter": - this._onKeyPressEnter(menu); + this._onKeyPressEnter(menu, e); break; case "Escape": @@ -471,7 +503,7 @@ } // Stop all processed events - e.preventDefault(); + e.stop(); }, @@ -665,14 +697,22 @@ * Event handler for <code>Enter</code> key * * @param menu {qx.ui.menu.Menu} The active menu + * @param e {qx.event.type.KeySequence} The keypress event * @return {void} */ - _onKeyPressEnter : function(menu) + _onKeyPressEnter : function(menu, e) { - // Execute the command behind the currently selected button + // Route keypress event to the selected button var selectedButton = menu.getSelectedButton(); - if (selectedButton) { - selectedButton.execute(); + if (selectedButton && selectedButton.hasListener("keypress")) + { + // Clone and reconfigure event + var clone = e.clone(); + clone.setBubbles(false); + clone.setTarget(selectedButton); + + // Finally dispatch the clone + selectedButton.dispatchEvent(clone); } // Hide all open menus Modified: trunk/qooxdoo/frontend/framework/source/class/qx/ui/menu/Menu.js =================================================================== --- trunk/qooxdoo/frontend/framework/source/class/qx/ui/menu/Menu.js 2008-07-23 12:07:44 UTC (rev 14746) +++ trunk/qooxdoo/frontend/framework/source/class/qx/ui/menu/Menu.js 2008-07-23 12:33:32 UTC (rev 14747) @@ -246,11 +246,25 @@ * * @param opener {qx.ui.core.Widget} Any widget */ - open : function(opener) + open : function(opener, align) { // Update opener - if (opener) { + if (opener) + { this.setOpener(opener); + + // Align menu + if (align) + { + var coords = opener.getContainerLocation(); + + switch(align) + { + case "bottom-left": + this.moveTo(coords.left, coords.bottom); + break; + } + } } // Move to correct position Modified: trunk/qooxdoo/frontend/framework/source/class/qx/ui/menu/RadioButton.js =================================================================== --- trunk/qooxdoo/frontend/framework/source/class/qx/ui/menu/RadioButton.js 2008-07-23 12:07:44 UTC (rev 14746) +++ trunk/qooxdoo/frontend/framework/source/class/qx/ui/menu/RadioButton.js 2008-07-23 12:33:32 UTC (rev 14747) @@ -134,6 +134,12 @@ // overridden _onMouseUp : function(e) { this.setChecked(true); + }, + + + // overridden + _onKeyPress : function(e) { + this.setChecked(true); } } }); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |