زمینه های سفارشی
با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
در حالی که Blockly زمینه های مفید زیادی را ارائه می دهد، برنامه شما ممکن است یک مورد تخصصی داشته باشد. در اینجا چند مرحله برای سفارشی کردن فیلدها وجود دارد:
اسناد مربوط به هر زمینه مشابه آنچه شما نیاز دارید را بخوانید. آنها ممکن است یک رابط مفید برای سفارشی سازی ارائه دهند. به عنوان مثال، کرکره ها عملکردهای پنهان زیادی دارند.
برای حل مشکل خود از یک اعتبارسنجی استفاده کنید. اعتباربخشها به شما اجازه میدهند که فقط مقادیر خاصی را بپذیرید، ورودی را تغییر دهید یا عملکرد را زمانی که مقدار یک فیلد تغییر میکند فعال کنید.
گسترش یک زمینه را در نظر بگیرید. اگر فیلدی وجود دارد که نشاندهنده نوع مقدار مورد نیاز شما است، اما میخواهید ویرایشگر آن، ظاهر آن یا متنی را که نمایش میدهد تغییر دهید، میتوانید یک زیر کلاس ایجاد کنید که بخش عمدهای از عملکرد را به ارث میبرد، در حالی که بخشهای خاصی را که میخواهید لغو کنید. عوض شدن.
یک نوع فیلد جدید ایجاد کنید. اگرچه این قویترین گزینه است، اما زمانبرترین است و معمولاً فقط در صورت نیاز به ذخیره یک نوع ارزش جدید استفاده میشود.
جز در مواردی که غیر از این ذکر شده باشد،محتوای این صفحه تحت مجوز Creative Commons Attribution 4.0 License است. نمونه کدها نیز دارای مجوز Apache 2.0 License است. برای اطلاع از جزئیات، به خطمشیهای سایت Google Developers مراجعه کنید. جاوا علامت تجاری ثبتشده Oracle و/یا شرکتهای وابسته به آن است.
تاریخ آخرین بهروزرسانی 2025-07-24 بهوقت ساعت هماهنگ جهانی.
[null,null,["تاریخ آخرین بهروزرسانی 2025-07-24 بهوقت ساعت هماهنگ جهانی."],[[["\u003cp\u003eBlockly offers customization options beyond its built-in fields, allowing developers to tailor fields to their specific needs.\u003c/p\u003e\n"],["\u003cp\u003eBefore creating a new field type, explore existing fields, validators, and extension capabilities for potential solutions.\u003c/p\u003e\n"],["\u003cp\u003eLeverage validators to control accepted values, modify input, or trigger actions based on field value changes.\u003c/p\u003e\n"],["\u003cp\u003eExtend existing fields to modify their editor, appearance, or displayed text while inheriting core functionality.\u003c/p\u003e\n"],["\u003cp\u003eCreating a new field type is the most powerful but time-intensive option, reserved for storing new value types.\u003c/p\u003e\n"]]],["Customizing Blockly fields involves several steps: First, review documentation of similar fields for potential customization options. Second, use validators to control accepted values, modify input, or trigger actions upon value changes. Third, extend existing fields by creating subclasses to modify their editor, appearance, or displayed text. Finally, create a new field type for storing novel value types, though this is the most complex option.\n"],null,["# Custom fields\n\nWhile Blockly provides many useful fields, your application may have a\nspecialized case. Here are a few steps to take when customizing fields:\n\n1. Read the documentation of any fields similar to what you require; they may\n provide a useful interface for customization. For example,\n [dropdowns](/blockly/guides/create-custom-blocks/fields/built-in-fields/dropdown) have a lot of hidden functionality.\n\n2. Consider using a [validator](/blockly/guides/create-custom-blocks/fields/validators) to solve your problem.\n Validators allow you to only accept certain values, modify input, or trigger\n functionality when a field's value changes.\n\n3. Consider [extending a field](/blockly/guides/create-custom-blocks/fields/customizing-fields/extending).\n If there is a field that represents the value type you require, but you want to\n modify its [editor](/blockly/guides/create-custom-blocks/fields/anatomy-of-a-field#editor_display), its\n [appearance](/blockly/guides/create-custom-blocks/fields/anatomy-of-a-field#on-block_display), or the\n [text](/blockly/guides/create-custom-blocks/fields/customizing-fields/creating#text) it\n displays, you can [create a subclass](/blockly/guides/create-custom-blocks/fields/customizing-fields/extending#subclassing)\n that inherits the bulk of the functionality, while overriding the specific parts\n you want to change.\n\n4. [Create a new field type](/blockly/guides/create-custom-blocks/fields/customizing-fields/creating).\n While this is the most powerful option, it is also the most time consuming, and\n should generally only be used if you need to store a new value type."]]