summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjmoenig <jens@moenig.org>2014-06-23 13:24:16 +0200
committerjmoenig <jens@moenig.org>2014-06-23 13:24:16 +0200
commit9c1d06b9ef03020989c39a10fea248ec993773e3 (patch)
tree3ff5378d6b34df08f2eb25f5080d5a0465ef21e8
parent7f8d5a3d1eacdc78f61da8e82ac481bbbb825938 (diff)
downloadsnap-9c1d06b9ef03020989c39a10fea248ec993773e3.tar.gz
snap-9c1d06b9ef03020989c39a10fea248ec993773e3.zip
Morphic: Inspector enhancements
dynamic property update, keyboard shortcuts
-rwxr-xr-xhistory.txt4
-rw-r--r--morphic.js70
2 files changed, 55 insertions, 19 deletions
diff --git a/history.txt b/history.txt
index 02fc2a0..dad28a4 100755
--- a/history.txt
+++ b/history.txt
@@ -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)
diff --git a/morphic.js b/morphic.js
index 7d1f53d..b951f3a 100644
--- a/morphic.js
+++ b/morphic.js
@@ -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);