diff options
| author | jmoenig <jens@moenig.org> | 2014-06-23 13:24:16 +0200 |
|---|---|---|
| committer | jmoenig <jens@moenig.org> | 2014-06-23 13:24:16 +0200 |
| commit | 9c1d06b9ef03020989c39a10fea248ec993773e3 (patch) | |
| tree | 3ff5378d6b34df08f2eb25f5080d5a0465ef21e8 /morphic.js | |
| parent | 7f8d5a3d1eacdc78f61da8e82ac481bbbb825938 (diff) | |
| download | snap-yow-9c1d06b9ef03020989c39a10fea248ec993773e3.tar.gz snap-yow-9c1d06b9ef03020989c39a10fea248ec993773e3.zip | |
Morphic: Inspector enhancements
dynamic property update, keyboard shortcuts
Diffstat (limited to 'morphic.js')
| -rw-r--r-- | morphic.js | 70 |
1 files changed, 51 insertions, 19 deletions
@@ -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); |
