Stay organized with collections
Save and categorize content based on your preferences.
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.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-09-18 UTC."],[[["\u003cp\u003eThe \u003ccode\u003esetDisabledReason()\u003c/code\u003e method manages the reasons a block is disabled, affecting the block's overall disabled state.\u003c/p\u003e\n"],["\u003cp\u003eIt takes a boolean (\u003ccode\u003edisabled\u003c/code\u003e) to indicate if the block should be disabled for the given reason, and a string (\u003ccode\u003ereason\u003c/code\u003e) to identify the specific reason.\u003c/p\u003e\n"],["\u003cp\u003eCalling \u003ccode\u003esetDisabledReason()\u003c/code\u003e with the same reason multiple times updates the block's disabled state for that reason.\u003c/p\u003e\n"],["\u003cp\u003eBlocks can be disabled for multiple reasons concurrently, accumulating reasons until all are removed for the block to be enabled.\u003c/p\u003e\n"]]],["The `Block.setDisabledReason()` method manages reasons for a block's disabled state. It takes a boolean `disabled` and a string `reason`. If `disabled` is true, the block is considered disabled for the given `reason`; otherwise, it's no longer disabled for that reason. Multiple reasons can simultaneously disable a block, and the `reason` parameter acts as a unique identifier for each condition. The method updates the block's disabled status for each reason and returns nothing.\n"],null,["[blockly](./blockly.md) \\\u003e [Block](./blockly.block_class.md) \\\u003e [setDisabledReason](./blockly.block_class.setdisabledreason_1_method.md)\n\nBlock.setDisabledReason() method\n--------------------------------\n\nAdd 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.\n\n**Signature:** \n\n setDisabledReason(disabled: boolean, reason: string): void;\n\nParameters\n----------\n\n| Parameter | Type | Description |\n|-----------|---------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| 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. |\n| 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. |\n\n**Returns:**\n\nvoid"]]