don't show visual report when monitor is running

This commit is contained in:
DD Liu 2017-05-08 16:51:45 -04:00
parent 706e112082
commit 26a5098347
3 changed files with 13 additions and 6 deletions

View file

@ -194,7 +194,7 @@ class Blocks {
// UI event: clicked scripts toggle in the runtime. // UI event: clicked scripts toggle in the runtime.
if (e.element === 'stackclick') { if (e.element === 'stackclick') {
if (optRuntime) { if (optRuntime) {
optRuntime.toggleScript(e.blockId); optRuntime.toggleScript(e.blockId, {showVisualReport: true});
} }
return; return;
} }

View file

@ -85,7 +85,7 @@ const execute = function (sequencer, thread) {
} else { } else {
// In a non-hat, report the value visually if necessary if // In a non-hat, report the value visually if necessary if
// at the top of the thread stack. // at the top of the thread stack.
if (typeof resolvedValue !== 'undefined' && thread.atStackTop()) { if (typeof resolvedValue !== 'undefined' && thread.showVisualReport && thread.atStackTop()) {
runtime.visualReport(currentBlockId, resolvedValue); runtime.visualReport(currentBlockId, resolvedValue);
} }
// Finished any yields. // Finished any yields.

View file

@ -369,11 +369,13 @@ class Runtime extends EventEmitter {
* Create a thread and push it to the list of threads. * Create a thread and push it to the list of threads.
* @param {!string} id ID of block that starts the stack. * @param {!string} id ID of block that starts the stack.
* @param {!Target} target Target to run thread on. * @param {!Target} target Target to run thread on.
* @param {?boolean} optShowVisualReport true if the script should show speech bubble for its value
* @return {!Thread} The newly created thread. * @return {!Thread} The newly created thread.
*/ */
_pushThread (id, target) { _pushThread (id, target, optShowVisualReport) {
const thread = new Thread(id); const thread = new Thread(id);
thread.target = target; thread.target = target;
thread.showVisualReport = optShowVisualReport;
thread.pushStack(id); thread.pushStack(id);
this.threads.push(thread); this.threads.push(thread);
return thread; return thread;
@ -423,9 +425,11 @@ class Runtime extends EventEmitter {
/** /**
* Toggle a script. * Toggle a script.
* @param {!string} topBlockId ID of block that starts the script. * @param {!string} topBlockId ID of block that starts the script.
* @param {?string} optTarget target ID for target to run script on. If not supplied, uses editing target. * @param {?object} opts optional arguments to toggle script
* @param {?string} opts.target target ID for target to run script on. If not supplied, uses editing target.
* @param {?boolean} opts.showVisualReport true if the speech bubble should pop up on the block, false if not.
*/ */
toggleScript (topBlockId, optTarget) { toggleScript (topBlockId, opts) {
// Remove any existing thread. // Remove any existing thread.
for (let i = 0; i < this.threads.length; i++) { for (let i = 0; i < this.threads.length; i++) {
if (this.threads[i].topBlock === topBlockId) { if (this.threads[i].topBlock === topBlockId) {
@ -434,7 +438,10 @@ class Runtime extends EventEmitter {
} }
} }
// Otherwise add it. // Otherwise add it.
this._pushThread(topBlockId, optTarget ? optTarget : this._editingTarget); this._pushThread(
topBlockId,
opts && opts.target ? opts.target : this._editingTarget,
opts ? opts.showVisualReport : false);
} }
/** /**