Morphic: Inspector enhancements

dynamic property update, keyboard shortcuts
pull/3/merge
jmoenig 2014-06-23 13:24:16 +02:00
rodzic 7f8d5a3d1e
commit 9c1d06b9ef
2 zmienionych plików z 55 dodań i 19 usunięć

Wyświetl plik

@ -2166,3 +2166,7 @@ ______
* Blocks: enable relabelling blocks across categories
* Objects: more relabelling options for SAY, THINK, ASK
* BYOB, Blocks: relabelling custom blocks (experimental)
140623
------
* Morphic: Inspector enhancements (dynamic property update, keyboard shortcuts)

Wyświetl plik

@ -1035,7 +1035,7 @@
/*global window, HTMLCanvasElement, getMinimumFontHeight, FileReader, Audio,
FileList, getBlurredShadowSupport*/
var morphicVersion = '2014-May-20';
var morphicVersion = '2014-June-23';
var modules = {}; // keep track of additional loaded modules
var useBlurredShadows = getBlurredShadowSupport(); // check for Chrome-bug
@ -4761,8 +4761,17 @@ CursorMorph.prototype.ctrl = function (aChar) {
this.insert(']');
} else if (aChar === 64) {
this.insert('@');
} else if (!isNil(this.target.receiver)) {
if (aChar === 68) {
this.target.doIt();
} else if (aChar === 73) {
this.target.inspectIt();
} else if (aChar === 80) {
this.target.showIt();
}
}
};
CursorMorph.prototype.cmd = function (aChar) {
@ -4770,6 +4779,14 @@ CursorMorph.prototype.cmd = function (aChar) {
this.target.selectAll();
} else if (aChar === 90) {
this.undo();
} else if (!isNil(this.target.receiver)) {
if (aChar === 68) {
this.target.doIt();
} else if (aChar === 73) {
this.target.inspectIt();
} else if (aChar === 80) {
this.target.showIt();
}
}
};
@ -6157,6 +6174,7 @@ InspectorMorph.prototype.init = function (target) {
this.edge = MorphicPreferences.isFlat ? 1 : 5;
this.color = new Color(60, 60, 60);
this.borderColor = new Color(95, 95, 95);
this.fps = 25;
this.drawNew();
// panes:
@ -6181,6 +6199,28 @@ InspectorMorph.prototype.setTarget = function (target) {
this.buildPanes();
};
InspectorMorph.prototype.updateCurrentSelection = function () {
var val, txt, cnts,
sel = this.list.selected;
if (isNil(sel)) {return; }
val = this.target[sel];
if (this.currentProperty === val) {return; }
this.currentProperty = val;
if (isNil(val)) {
txt = 'NULL';
} else if (isString(val)) {
txt = val;
} else {
txt = val.toString();
}
cnts = new TextMorph(txt);
cnts.isEditable = true;
cnts.enableSelecting();
cnts.setReceiver(this.target);
this.detail.setContents(cnts);
};
InspectorMorph.prototype.buildPanes = function () {
var attribs = [], property, myself = this, ctrl, ev, doubleClickAction;
@ -6248,23 +6288,8 @@ InspectorMorph.prototype.buildPanes = function () {
doubleClickAction
);
this.list.action = function (selected) {
var val, txt, cnts;
if (selected === undefined) {return; }
val = myself.target[selected];
myself.currentProperty = val;
if (val === null) {
txt = 'NULL';
} else if (isString(val)) {
txt = val;
} else {
txt = val.toString();
}
cnts = new TextMorph(txt);
cnts.isEditable = true;
cnts.enableSelecting();
cnts.setReceiver(myself.target);
myself.detail.setContents(cnts);
this.list.action = function () {
myself.updateCurrentSelection();
};
this.list.hBar.alpha = 0.6;
@ -6582,6 +6607,13 @@ InspectorMorph.prototype.removeProperty = function () {
}
};
// InspectorMorph stepping
InspectorMorph.prototype.step = function () {
if (!isObject(this.currentProperty)) {return; }
this.updateCurrentSelection();
};
// MenuMorph ///////////////////////////////////////////////////////////
// MenuMorph: referenced constructors
@ -7924,7 +7956,7 @@ TextMorph.prototype.inspectIt = function () {
var result = this.receiver.evaluateString(this.selection()),
world = this.world(),
inspector;
if (result !== null) {
if (isObject(result)) {
inspector = new InspectorMorph(result);
inspector.setPosition(world.hand.position());
inspector.keepWithin(world);