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: select new variable blocks' monitor checkboxes after creation (#… · SnoopyMod/scratch-blocks@3811d93

File tree

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

‎src/scratch_continuous_toolbox.js‎

Copy file name to clipboardExpand all lines: src/scratch_continuous_toolbox.js
+10Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,21 @@ import * as Blockly from "blockly/core";
22
import { ContinuousToolbox } from "@blockly/continuous-toolbox";
33

44
export class ScratchContinuousToolbox extends ContinuousToolbox {
5+
postRenderCallbacks = [];
6+
57
refreshSelection() {
68
// Intentionally a no-op, Scratch manually manages refreshing the toolbox via forceRerender().
79
}
810

911
forceRerender() {
1012
super.refreshSelection();
13+
let callback;
14+
while ((callback = this.postRenderCallbacks.shift())) {
15+
callback();
16+
}
17+
}
18+
19+
runAfterRerender(callback) {
20+
this.postRenderCallbacks.push(callback);
1121
}
1222
}
Collapse file

‎src/variables.js‎

Copy file name to clipboardExpand all lines: src/variables.js
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,9 @@ export function createVariable(workspace, opt_callback, opt_type) {
117117

118118
var flyout = workspace.isFlyout ? workspace : workspace.getFlyout();
119119
var variableBlockId = variable.getId();
120-
if (flyout.setCheckboxState) {
120+
workspace.getToolbox().runAfterRerender(() => {
121121
flyout.setCheckboxState(variableBlockId, true);
122-
}
122+
});
123123

124124
if (opt_callback) {
125125
opt_callback(variableBlockId);

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.