Add ctrl-enter to edit a node and all references

This commit is contained in:
Ian Gulliver
2019-07-16 17:24:24 +00:00
parent ccf4299d5a
commit a66bee672d
5 changed files with 49 additions and 4 deletions

View File

@@ -5,10 +5,11 @@ class EditorInputBase extends EditorEntryBase {
this.input_ = document.createElement('input');
this.input_.type = 'text';
this.listen(this.input_, 'keydown', (e) => this.onInputKeyDown(e));
this.listen(this.input_, 'input', (e) => this.onInput(e));
this.listen(this.input_, 'input', () => this.onInput());
this.listen(this.input_, 'blur', (e) => this.onBlur(e));
this.elem_.appendChild(this.input_);
this.lastLabel_ = '';
this.lastSnapshotLabel_ = '';
if (label) {
@@ -33,15 +34,16 @@ class EditorInputBase extends EditorEntryBase {
setLabel(label) {
this.input_.value = label;
this.lastSnapshotLabel_ = label;
this.onInput();
this.updateLabel();
}
wantFocus() {
return this.getLabel() == '';
}
onInput() {
this.requestRender();
updateLabel() {
this.lastLabel_ = this.getLabel();
let objs = document.getElementsByClassName('grid-' + this.getId());
if (objs.length == 1) {
objs[0].innerText = this.getLabel();
@@ -49,6 +51,11 @@ class EditorInputBase extends EditorEntryBase {
}
}
onInput() {
this.updateLabel();
this.requestRender();
}
onBlur() {
if (this.getLabel() != this.lastSnapshotLabel_) {
this.lastSnapshotLabel_ = this.getLabel();
@@ -95,6 +102,7 @@ class EditorInputBase extends EditorEntryBase {
switch (e.key) {
case 'ArrowRight':
case 'Enter':
this.ctrlKey_ = e.ctrlKey;
this.startEdit();
e.stopPropagation();
e.preventDefault();