GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix: improve reliability of block value reporting (#77) · scratchfoundation/scratch-blocks@cb5b068

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • src
    • block_reporting.js
    • checkable_continuous_flyout.js
    • index.js
    • scratch_continuous_toolbox.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/block_reporting.js‎

Copy file name to clipboardExpand all lines: src/block_reporting.js
+10-1Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,16 @@ export function reportValue(id, value) {
77
if (!block) {
88
throw 'Tried to report value on block that does not exist.';
99
}
10-
const field = block.inputList[0].fieldRow[0];
10+
11+
let field;
12+
for (const input of block.inputList) {
13+
for (const f of input.fieldRow) {
14+
field = f;
15+
break;
16+
}
17+
}
18+
if (!field) return;
19+
1120
const contentDiv = Blockly.DropDownDiv.getContentDiv();
1221
const valueReportBox = document.createElement('div');
1322
valueReportBox.setAttribute('class', 'valueReportBox');
Collapse file

‎src/checkable_continuous_flyout.js‎

Copy file name to clipboardExpand all lines: src/checkable_continuous_flyout.js
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,4 +218,12 @@ export class CheckableContinuousFlyout extends ContinuousFlyout {
218218
getFlyoutScale() {
219219
return 0.675;
220220
}
221+
222+
blockIsRecyclable_(block) {
223+
const recyclable = super.blockIsRecyclable_(block);
224+
// Exclude blocks with output connections, because they are able to report their current
225+
// value in a popover and recycling them interacts poorly with the VM's maintenance of its
226+
// state.
227+
return recyclable && !block.outputConnection;
228+
}
221229
}
Collapse file

‎src/index.js‎

Copy file name to clipboardExpand all lines: src/index.js
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import {
3131
ContinuousMetrics,
3232
} from '@blockly/continuous-toolbox';
3333
import {CheckableContinuousFlyout} from './checkable_continuous_flyout.js';
34+
import {ScratchContinuousToolbox} from './scratch_continuous_toolbox.js';
3435
import {buildGlowFilter, glowStack} from './glows.js';
3536
import './scratch_continuous_category.js';
3637

@@ -51,7 +52,7 @@ export {CheckableContinuousFlyout};
5152
export function inject(container, options) {
5253
Object.assign(options, {
5354
plugins: {
54-
toolbox: ContinuousToolbox,
55+
toolbox: ScratchContinuousToolbox,
5556
flyoutsVerticalToolbox: CheckableContinuousFlyout,
5657
metricsManager: ContinuousMetrics,
5758
},
Collapse file

‎src/scratch_continuous_toolbox.js‎

Copy file name to clipboard
+12Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import * as Blockly from 'blockly/core';
2+
import {ContinuousToolbox} from '@blockly/continuous-toolbox';
3+
4+
export class ScratchContinuousToolbox extends ContinuousToolbox {
5+
refreshSelection() {
6+
// Intentionally a no-op, Scratch manually manages refreshing the toolbox via forceRerender().
7+
}
8+
9+
forceRerender() {
10+
super.refreshSelection();
11+
}
12+
}

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.