blockly > Block > setDisabledReason
Block.setDisabledReason() method
Add or remove a reason why the block might be disabled. If a block has any reasons to be disabled, then the block itself will be considered disabled. A block could be disabled for multiple independent reasons simultaneously, such as when the user manually disables it, or the block is invalid.
Signature:
setDisabledReason(disabled: boolean, reason: string): void;
Parameters
Parameter |
Type |
Description |
disabled |
boolean |
If true, then the block should be considered disabled for at least the provided reason, otherwise the block is no longer disabled for that reason. |
reason |
string |
A language-neutral identifier for a reason why the block could be disabled. Call this method again with the same identifier to update whether the block is currently disabled for this reason. |
Returns:
void
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-09-18 UTC.
[null,null,["Last updated 2024-09-18 UTC."],[[["The `setDisabledReason()` method manages the reasons a block is disabled, affecting the block's overall disabled state."],["It takes a boolean (`disabled`) to indicate if the block should be disabled for the given reason, and a string (`reason`) to identify the specific reason."],["Calling `setDisabledReason()` with the same reason multiple times updates the block's disabled state for that reason."],["Blocks can be disabled for multiple reasons concurrently, accumulating reasons until all are removed for the block to be enabled."]]],[]]