Customizing fields
Stay organized with collections
Save and categorize content based on your preferences.
While Blockly provides many useful fields, your application may have a
specialized case. Here are a few steps to take when customizing fields:
Read the documentation of any fields similar to what you require; they may
provide a useful interface for customization. For example,
dropdowns have a lot of hidden functionality.
Consider using a validator to solve your problem.
Validators allow you to only accept certain values, modify input, or trigger
functionality when a field's value changes.
Consider extending a field.
If there is a field that represents the value type you require, but you want to
modify its editor, its
appearance, or the
text it
displays, you can create a subclass
that inherits the bulk of the functionality, while overriding the specific parts
you want to change.
Create a new field type.
While this is the most powerful option, it is also the most time consuming, and
should generally only be used if you need to store a new value type.
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."],[[["Blockly offers customization options beyond its built-in fields, allowing developers to tailor fields to their specific needs."],["Before creating a new field type, explore existing fields, validators, and extension capabilities for potential solutions."],["Leverage validators to control accepted values, modify input, or trigger actions based on field value changes."],["Extend existing fields to modify their editor, appearance, or displayed text while inheriting core functionality."],["Creating a new field type is the most powerful but time-intensive option, reserved for storing new value types."]]],[]]