blockly > Blockieren > setDisabledReason
Methode Block.setDisabledReason()
Geben Sie einen Grund für die Deaktivierung der Blockierung an oder entfernen Sie einen Grund. Wenn eine Blockierung einen Grund für die Deaktivierung hat, wird die Blockierung selbst als deaktiviert betrachtet. Eine Blockierung kann aus mehreren unterschiedlichen Gründen gleichzeitig deaktiviert werden, z. B. wenn der Nutzer sie manuell deaktiviert oder die Blockierung ungültig ist.
Unterschrift:
setDisabledReason(disabled: boolean, reason: string): void;
Parameter
Parameter |
Typ |
Beschreibung |
deaktiviert |
boolean |
Bei „true“ sollte die Blockierung zumindest aus dem angegebenen Grund als deaktiviert betrachtet werden. Andernfalls ist die Blockierung aus diesem Grund nicht mehr deaktiviert. |
reason |
String |
Eine sprachneutrale Kennung aus einem Grund, warum die Blockierung deaktiviert werden könnte. Rufen Sie diese Methode noch einmal mit derselben ID auf, um zu aktualisieren, ob der Block derzeit aus diesem Grund deaktiviert ist. |
Gibt zurück:
voidm
Sofern nicht anders angegeben, sind die Inhalte dieser Seite unter der Creative Commons Attribution 4.0 License und Codebeispiele unter der Apache 2.0 License lizenziert. Weitere Informationen finden Sie in den Websiterichtlinien von Google Developers. Java ist eine eingetragene Marke von Oracle und/oder seinen Partnern.
Zuletzt aktualisiert: 2024-08-22 (UTC).
[null,null,["Zuletzt aktualisiert: 2024-08-22 (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."]]],["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"]]