Changeset 12597

Show
Ignore:
Timestamp:
02/21/08 13:35:03 (11 months ago)
Author:
doughays
Message:

Fixes #5917. Changed ComboBoxMixin? to use the _FormWidget:_onKeyPressed to manage undo.

Location:
dijit/trunk/form
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • dijit/trunk/form/ComboBox.js

    r12572 r12597  
    7676 
    7777                baseClass:"dijitComboBox", 
    78  
    79                 _lastDisplayedValue: "", 
    80  
    81                 setDisplayedValue:function(/*String*/ value){ 
    82                         this._lastDisplayedValue = value; 
    83                         this.setValue(value, true); 
    84                 }, 
    8578 
    8679                _getCaretPos: function(/*DomNode*/ element){ 
     
    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 
     
    10541042 
    10551043 
     1044 
  • dijit/trunk/form/FilteringSelect.js

    r12572 r12597  
    3838 
    3939                _isvalid:true, 
     40 
     41                _lastDisplayedValue: "", 
    4042 
    4143                isValid:function(){ 
     
    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        } 
  • dijit/trunk/form/_FormWidget.js

    r12572 r12597  
    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);