ve.ui.SelectWidget: Keep track of mouse down

This helps with some differences between browsers, specifically Firefox,
where e.which would be "1" even if the mouse button was not pressed.

Change-Id: Ia88449c2bc84073d903dc702bb586127618d86f2
This commit is contained in:
Trevor Parscal 2013-04-15 11:46:13 -07:00 committed by Krinkle
parent 17c9aadf8f
commit 8f6b042eaf

View file

@ -27,7 +27,7 @@ ve.ui.SelectWidget = function VeUiSelectWidget( config ) {
ve.ui.GroupElement.call( this, this.$, config );
// Properties
this.dragging = false;
this.pressed = false;
this.selecting = null;
this.hashes = {};
@ -73,6 +73,7 @@ ve.ui.SelectWidget.prototype.onMouseDown = function ( e ) {
var item;
if ( !this.disabled && e.which === 1 ) {
this.pressed = true;
item = this.getTargetItem( e );
if ( item && item.isSelectable() ) {
this.selectItem( item, true );
@ -91,6 +92,7 @@ ve.ui.SelectWidget.prototype.onMouseDown = function ( e ) {
* @param {jQuery.Event} e Mouse down event
*/
ve.ui.SelectWidget.prototype.onMouseUp = function ( e ) {
this.pressed = false;
if ( !this.disabled && e.which === 1 && this.selecting ) {
this.selectItem( this.selecting );
this.selecting = null;
@ -108,7 +110,7 @@ ve.ui.SelectWidget.prototype.onMouseUp = function ( e ) {
ve.ui.SelectWidget.prototype.onMouseMove = function ( e ) {
var item;
if ( !this.disabled && e.which === 1 ) {
if ( !this.disabled && this.pressed ) {
item = this.getTargetItem( e );
if ( item && item !== this.selecting && item.isSelectable() ) {
this.selectItem( item, true );