summaryrefslogtreecommitdiff
path: root/morphic.js
diff options
context:
space:
mode:
authorjmoenig <jens@moenig.org>2014-07-11 11:16:05 +0200
committerjmoenig <jens@moenig.org>2014-07-11 11:16:05 +0200
commit05c74826888fb70247db5d5f37b6a8e4162f5ca4 (patch)
tree980406efe80c4c666091ff4ba126f5594ffc9423 /morphic.js
parentd372e807a5ac57cab533e06f6249bec2d28a0d37 (diff)
downloadsnap-yow-05c74826888fb70247db5d5f37b6a8e4162f5ca4.tar.gz
snap-yow-05c74826888fb70247db5d5f37b6a8e4162f5ca4.zip
Morphic: directly edit properties in inspectors
Diffstat (limited to 'morphic.js')
-rw-r--r--morphic.js17
1 files changed, 14 insertions, 3 deletions
diff --git a/morphic.js b/morphic.js
index 2690f06..6d93439 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();