Ticket #5917: 5917.patch

File 5917.patch, 3.0 kB (added by haysmark, 11 months ago)

Fixes #5917. Fix escape key handling in ComboBox?.

  • form/_FormWidget.js

     
    316316                this.setValue(this._lastValueReported, false); 
    317317        }, 
    318318 
     319        _valueChanged: function(){ 
     320                var v = this.getValue(); 
     321                var lv = this._lastValueReported; 
     322                // Equality comparison of objects such as dates are done by reference so 
     323                // two distinct objects are != even if they have the same data. So use 
     324                // toStrings in case the values are objects. 
     325                return ((v !== null && (v !== undefined) && v.toString)?v.toString():null) !== ((lv !== null && (lv !== undefined) && lv.toString)?lv.toString():null); 
     326        }, 
     327 
    319328        _onKeyPress: function(e){ 
    320329                if(e.keyCode == dojo.keys.ESCAPE && !e.shiftKey && !e.ctrlKey && !e.altKey){ 
    321                         var v = this.getValue(); 
    322                         var lv = this._lastValueReported; 
    323                         // Equality comparison of objects such as dates are done by reference so 
    324                         // two distinct objects are != even if they have the same data. So use 
    325                         // toStrings in case the values are objects. 
    326                         if(((v !== null && (v !== undefined) && v.toString)?v.toString():null) !== ((lv !== null && (lv !== undefined) && lv.toString)?lv.toString():null)){ 
     330                        if(this._valueChanged()){ 
    327331                                this.undo(); 
    328332                                dojo.stopEvent(e); 
    329333                                return false; 
  • form/ComboBox.js

     
    7676 
    7777                baseClass:"dijitComboBox", 
    7878 
    79                 _lastDisplayedValue: "", 
    80  
    81                 setDisplayedValue:function(/*String*/ value){ 
    82                         this._lastDisplayedValue = value; 
    83                         this.setValue(value, true); 
    84                 }, 
    85  
    8679                _getCaretPos: function(/*DomNode*/ element){ 
    8780                        // khtml 3.5.2 has selection* methods as does webkit nightlies from 2005-06-22 
    8881                        var pos = 0; 
     
    258251                                        this._prev_key_backspace = false; 
    259252                                        this._prev_key_esc = true; 
    260253                                        this._hideResultList(); 
    261                                         if(this._lastDisplayedValue != this.getDisplayedValue()){ 
    262                                                 this.setDisplayedValue(this._lastDisplayedValue); 
    263                                                 dojo.stopEvent(evt); 
    264                                         }else{ 
    265                                                 this.setValue(this.getValue(), false); 
    266                                         } 
     254                                        this.inherited(arguments); 
    267255                                        break; 
    268256 
    269257                                case dk.DELETE: 
  • form/FilteringSelect.js

     
    3838 
    3939                _isvalid:true, 
    4040 
     41                _lastDisplayedValue: "", 
     42 
    4143                isValid:function(){ 
    4244                        return this._isvalid; 
    4345                }, 
     
    217219                setAttribute: function(/*String*/ attr, /*anything*/ value){ 
    218220                        dijit.form.MappedTextBox.prototype.setAttribute.apply(this, arguments); 
    219221                        dijit.form.ComboBoxMixin.prototype._setAttribute.apply(this, arguments); 
     222                }, 
     223 
     224                undo: function(){ 
     225                        this.setDisplayedValue(this._lastDisplayedValue); 
     226                }, 
     227 
     228                _valueChanged: function(){ 
     229                        return this.getDisplayedValue()!=this._lastDisplayedValue; 
    220230                } 
    221231        } 
    222232);