(object, property)
| 24 | */ |
| 25 | class StringController extends Controller { |
| 26 | constructor(object, property) { |
| 27 | super(object, property); |
| 28 | |
| 29 | const _this = this; |
| 30 | |
| 31 | function onChange() { |
| 32 | _this.setValue(_this.__input.value); |
| 33 | } |
| 34 | |
| 35 | function onBlur() { |
| 36 | if (_this.__onFinishChange) { |
| 37 | _this.__onFinishChange.call(_this, _this.getValue()); |
| 38 | } |
| 39 | } |
| 40 | |
| 41 | this.__input = document.createElement('input'); |
| 42 | this.__input.setAttribute('type', 'text'); |
| 43 | |
| 44 | dom.bind(this.__input, 'keyup', onChange); |
| 45 | dom.bind(this.__input, 'change', onChange); |
| 46 | dom.bind(this.__input, 'blur', onBlur); |
| 47 | dom.bind(this.__input, 'keydown', function(e) { |
| 48 | if (e.keyCode === 13) { |
| 49 | this.blur(); |
| 50 | } |
| 51 | }); |
| 52 | |
| 53 | this.updateDisplay(); |
| 54 | |
| 55 | this.domElement.appendChild(this.__input); |
| 56 | } |
| 57 | |
| 58 | updateDisplay() { |
| 59 | // Stops the caret from moving on account of: |
nothing calls this directly
no test coverage detected