blockly > BlockSvg > setDisabledReason
BlockSvg.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 might be disabled, allowing for multiple reasons to coexist."],["It takes a boolean (`disabled`) indicating if the block should be disabled for the given reason and a string (`reason`) identifying the reason for disabling."],["By calling this method with the same `reason` and toggling `disabled`, you can dynamically update the block's disabled status for that specific reason."],["If any reason for disabling exists, the block will be considered disabled overall."]]],[]]