X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/6746dc89c47ed01b165cc1152533605f97eb8e8d..f562e4c6e5fac7bcb445985b99acbea4d706e6f0:/src/selection/RowModel.js diff --git a/src/selection/RowModel.js b/src/selection/RowModel.js index ffba95c3..4fc5afcd 100644 --- a/src/selection/RowModel.js +++ b/src/selection/RowModel.js @@ -15,10 +15,6 @@ If you are unsure which license is appropriate for your use, please contact the /** * @class Ext.selection.RowModel * @extends Ext.selection.Model - * - * Implement row based navigation via keyboard. - * - * Must synchronize across grid sections */ Ext.define('Ext.selection.RowModel', { extend: 'Ext.selection.Model', @@ -35,9 +31,17 @@ Ext.define('Ext.selection.RowModel', { /** * @cfg {Boolean} enableKeyNav * - * Turns on/off keyboard navigation within the grid. Defaults to true. + * Turns on/off keyboard navigation within the grid. */ enableKeyNav: true, + + /** + * @cfg {Boolean} [ignoreRightMouseSelection=true] + * True to ignore selections that are made when using the right mouse button if there are + * records that are already selected. If no records are selected, selection will continue + * as normal + */ + ignoreRightMouseSelection: true, constructor: function(){ this.addEvents( @@ -45,7 +49,7 @@ Ext.define('Ext.selection.RowModel', { * @event beforedeselect * Fired before a record is deselected. If any listener returns false, the * deselection is cancelled. - * @param {Ext.selection.RowSelectionModel} this + * @param {Ext.selection.RowModel} this * @param {Ext.data.Model} record The deselected record * @param {Number} index The row index deselected */ @@ -55,7 +59,7 @@ Ext.define('Ext.selection.RowModel', { * @event beforeselect * Fired before a record is selected. If any listener returns false, the * selection is cancelled. - * @param {Ext.selection.RowSelectionModel} this + * @param {Ext.selection.RowModel} this * @param {Ext.data.Model} record The selected record * @param {Number} index The row index selected */ @@ -64,7 +68,7 @@ Ext.define('Ext.selection.RowModel', { /** * @event deselect * Fired after a record is deselected - * @param {Ext.selection.RowSelectionModel} this + * @param {Ext.selection.RowModel} this * @param {Ext.data.Model} record The deselected record * @param {Number} index The row index deselected */ @@ -73,7 +77,7 @@ Ext.define('Ext.selection.RowModel', { /** * @event select * Fired after a record is selected - * @param {Ext.selection.RowSelectionModel} this + * @param {Ext.selection.RowModel} this * @param {Ext.data.Model} record The selected record * @param {Number} index The row index selected */ @@ -354,8 +358,26 @@ Ext.define('Ext.selection.RowModel', { // we can take into account ctrlKey, shiftKey, etc onRowMouseDown: function(view, record, item, index, e) { view.el.focus(); + if (!this.allowRightMouseSelection(e)) { + return; + } this.selectWithEvent(record, e); }, + + /** + * Checks whether a selection should proceed based on the ignoreRightMouseSelection + * option. + * @private + * @param {Ext.EventObject} e The event + * @return {Boolean} False if the selection should not proceed + */ + allowRightMouseSelection: function(e) { + var disallow = this.ignoreRightMouseSelection && e.button !== 0; + if (disallow) { + disallow = this.hasSelection(); + } + return !disallow; + }, // Allow the GridView to update the UI by // adding/removing a CSS class from the row.