-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: reenable reporting block values (#55)
* fix: reenable reporting block values * fix: make reporter bubbles appear on the correct block * fix: avoid error when attempting to report values of nonexistent blocks
- Loading branch information
Showing
3 changed files
with
32 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import * as Blockly from 'blockly/core'; | ||
import {Colours} from '../core/colours.js'; | ||
|
||
export function reportValue(id, value) { | ||
const block = Blockly.getMainWorkspace().getBlockById(id) || | ||
Blockly.getMainWorkspace().getFlyout().getWorkspace().getBlockById(id); | ||
if (!block) { | ||
throw 'Tried to report value on block that does not exist.'; | ||
} | ||
const field = block.inputList[0].fieldRow[0]; | ||
const contentDiv = Blockly.DropDownDiv.getContentDiv(); | ||
const valueReportBox = document.createElement('div'); | ||
valueReportBox.setAttribute('class', 'valueReportBox'); | ||
valueReportBox.innerText = value; | ||
contentDiv.appendChild(valueReportBox); | ||
Blockly.DropDownDiv.setColour( | ||
Colours.valueReportBackground, | ||
Colours.valueReportBorder | ||
); | ||
Blockly.DropDownDiv.showPositionedByBlock(field, block); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters