From 05c74826888fb70247db5d5f37b6a8e4162f5ca4 Mon Sep 17 00:00:00 2001 From: jmoenig Date: Fri, 11 Jul 2014 11:16:05 +0200 Subject: [PATCH] Morphic: directly edit properties in inspectors --- history.txt | 3 ++- morphic.js | 17 ++++++++++++++--- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/history.txt b/history.txt index e81f9971..f5ac9073 100755 --- a/history.txt +++ b/history.txt @@ -2190,4 +2190,5 @@ ______ 140711 ------ -* Morphic: keyboard shortcut ctrl/cmd-shift-a for @ +* Morphic: keyboard shortcut ctrl/cmd-shift-a for ‘@‘ +* Morphic: allow directly editing properties in inspector widgets diff --git a/morphic.js b/morphic.js index 2690f06d..6d934391 100644 --- a/morphic.js +++ b/morphic.js @@ -6160,6 +6160,7 @@ InspectorMorph.prototype.init = function (target) { this.currentProperty = null; this.showing = 'attributes'; this.markOwnProperties = false; + this.hasUserEditedDetails = false; // initialize inherited properties: InspectorMorph.uber.init.call(this); @@ -6203,9 +6204,17 @@ InspectorMorph.prototype.setTarget = function (target) { InspectorMorph.prototype.updateCurrentSelection = function () { var val, txt, cnts, - sel = this.list.selected; + sel = this.list.selected, + currentTxt = this.detail.contents.children[0], + root = this.root(); - if (isNil(sel)) {return; } + if (root && + (root.keyboardReceiver instanceof CursorMorph) && + (root.keyboardReceiver.target === currentTxt)) { + this.hasUserEditedDetails = true; + return; + } + if (isNil(sel) || this.hasUserEditedDetails) {return; } val = this.target[sel]; this.currentProperty = val; if (isNil(val)) { @@ -6215,7 +6224,7 @@ InspectorMorph.prototype.updateCurrentSelection = function () { } else { txt = val.toString(); } - if (this.detail.contents.children[0].text === txt) {return; } + if (currentTxt.text === txt) {return; } cnts = new TextMorph(txt); cnts.isEditable = true; cnts.enableSelecting(); @@ -6291,6 +6300,7 @@ InspectorMorph.prototype.buildPanes = function () { ); this.list.action = function () { + myself.hasUserEditedDetails = false; myself.updateCurrentSelection(); }; @@ -6539,6 +6549,7 @@ InspectorMorph.prototype.save = function () { try { // this.target[prop] = evaluate(txt); this.target.evaluateString('this.' + prop + ' = ' + txt); + this.hasUserEditedDetails = false; if (this.target.drawNew) { this.target.changed(); this.target.drawNew();