Skip to content

Add callback for setting checkbox state #908

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion core/flyout_vertical.js
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,7 @@ Blockly.VerticalFlyout.prototype.createRect_ = function(block, x, y,
*/
Blockly.VerticalFlyout.prototype.createCheckbox_ = function(block, cursorX,
cursorY, blockHW) {
var checkboxState = Blockly.VerticalFlyout.getCheckboxState(block.id);
var svgRoot = block.getSvgRoot();
var extraSpace = this.CHECKBOX_SIZE + this.CHECKBOX_MARGIN;
var width = this.RTL ? this.getWidth() / this.workspace_.scale - extraSpace : cursorX;
Expand All @@ -525,7 +526,12 @@ Blockly.VerticalFlyout.prototype.createCheckbox_ = function(block, cursorX,
'class': 'blocklyFlyoutCheckboxPath',
'd': this.CHECKMARK_PATH
}, checkboxGroup);
var checkboxObj = {svgRoot: checkboxGroup, clicked: false, block: block};
var checkboxObj = {svgRoot: checkboxGroup, clicked: checkboxState, block: block};

if (checkboxState) {
Blockly.utils.addClass((checkboxObj.svgRoot), 'checked');
}

block.flyoutCheckbox = checkboxObj;
this.workspace_.getCanvas().insertBefore(checkboxGroup, svgRoot);
this.checkboxes_.push(checkboxObj);
Expand Down Expand Up @@ -717,3 +723,13 @@ Blockly.VerticalFlyout.prototype.reflowInternal_ = function(/* blocks */) {
// This is a no-op because the flyout is a fixed size.
return;
};

/**
* Gets the checkbox state for a block
* @param {string} blockId The ID of the block in question.
* @return {boolean} Whether the block is checked.

This comment was marked as abuse.

* @public
*/
Blockly.VerticalFlyout.getCheckboxState = function(/* blockId */) {
return false;
};