Stay organized with collections
Save and categorize content based on your preferences.
blockly > Extensions
Extensions namespace
Functions
Function |
Description |
apply(name, block, isMutator) |
Applies an extension method to a block. This should only be called during block construction. |
buildTooltipForDropdown(dropdownName, lookupTable) |
Builds an extension function that will map a dropdown value to a tooltip string. |
buildTooltipWithFieldText(msgTemplate, fieldName) |
Builds an extension function that will install a dynamic tooltip. The tooltip message should include the string '%1' and that string will be replaced with the text of the named field. |
isRegistered(name) |
Returns whether an extension is registered with the given name. |
register(name, initFn) |
Registers a new extension function. Extensions are functions that help initialize blocks, usually adding dynamic behavior such as onchange handlers and mutators. These are applied using Block.applyExtension(), or the JSON "extensions" array attribute. |
registerMixin(name, mixinObj) |
Registers a new extension function that adds all key/value of mixinObj. |
registerMutator(name, mixinObj, opt_helperFn, opt_blockList) |
Registers a new extension function that adds a mutator to the block. At register time this performs some basic sanity checks on the mutator. The wrapper may also add a mutator dialog to the block, if both compose and decompose are defined on the mixin. |
unregister(name) |
Unregisters the extension registered with the given name. |
Variables
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."],[[["The Blockly Extensions namespace provides functions for registering, applying, and managing extensions that add functionality to blocks."],["Extensions can define dynamic behaviors like onchange handlers, mutators, and tooltips, enhancing block interactions."],["They are applied to blocks using `Block.applyExtension()` or the JSON \"extensions\" array attribute during block creation."],["Several helper functions are available for building tooltips and registering different types of extensions, including mixins and mutators."],["The namespace also includes functions for checking registration status and unregistering extensions."]]],["The Extensions namespace manages block extensions in Blockly. Key actions include: applying extensions to blocks during construction; building tooltip extensions that map dropdown values or field text to tooltip strings. It also handles registering and unregistering extensions, including those for dynamic behavior, and mixins. Mutator extensions can be registered as well, with optional helper functions and block lists, while also adding a mutator dialog to the block, when needed. It checks if an extension is already registered.\n"]]