แบบสำรวจการวิจัย: บอกให้เราทราบเกี่ยวกับประสบการณ์การใช้งาน Blockly
เริ่มแบบสำรวจ
ขยายช่องที่มีอยู่
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
ในการขยายช่องที่มีอยู่ คุณต้องจัดประเภทย่อยช่องข้อมูลที่มีอยู่แล้ว (เช่น
FieldTextInput
, FieldColour
) แล้วแก้ไขบางส่วนให้เหมาะกับความต้องการของคุณ
บางส่วนของช่องที่แก้ไขได้ ได้แก่
หากต้องการสร้าง
ช่องที่กำหนดเอง
ที่ไม่ต้องการลักษณะการทำงานจากช่องในตัว คุณควรคลาสย่อย Field
ส่วนขยายทั่วไป
ช่องที่กำหนดเองส่วนใหญ่จะขยายหนึ่งใน 3 ประเภทต่อไปนี้
- การป้อนข้อความ: หากต้องการให้ผู้ใช้พิมพ์ลงในช่องของคุณ คุณควรขยาย
FieldTextInput
- ตัวเลข: หากต้องการเก็บตัวเลขไว้ ควรขยายเวลาไว้ที่
FieldNumber
- เมนูแบบเลื่อนลง: หากต้องการสร้างเมนูแบบเลื่อนลงแต่ต้องการจัดเก็บโมเดลอื่น
สตริงหรือรูปแบบรูปภาพเริ่มต้น คุณควรขยาย
FieldDropdown
- ข้อควรระวัง: ก่อนที่จะขยาย
FieldDropdown
โปรดตรวจสอบว่าช่องแบบเลื่อนลง
ตัวเลือกการปรับแต่งไม่สามารถเติมเต็มความต้องการของคุณได้
ในบางสถานการณ์ คุณอาจต้องการขยายฟิลด์ประเภทอื่น สำหรับ
ตัวอย่าง FieldLabelSerializable
จะขยายไป FieldLabel
คลาสย่อย
import * as Blockly from 'blockly';
export class MyCustomTextField extends Blockly.FieldTextInput {
constructor(value, validator, config) {
super(value, validator, config);
}
}
ตัวสร้างสำหรับคลาสย่อยของช่องดูคล้ายกับตัวสร้างสำหรับ
ช่องที่กำหนดเอง ลายเซ็นของตัวสร้างย่อยควร
มักตรงกับลายเซ็นของตัวสร้างระดับสูง
JSON และการลงทะเบียน
คุณควรลงทะเบียนช่องนี้เพียงครั้งเดียวด้วย
Blockly.fieldRegistry.register('my_custom_text_field', MyCustomTextField);
และนำ fromJson
ไปใช้งานในชั้นเรียนเพื่อให้ใช้ร่วมกับ
รูปแบบ JSON
static fromJson(options) {
const value = Blockly.utils.parsing.replaceMessageReferences(options.value);
return new MySubclassName(value);
}
โปรดดูข้อมูลเพิ่มเติมเกี่ยวกับการลงทะเบียนช่องที่ JSON และการลงทะเบียน
ในส่วนการสร้างฟิลด์ที่กำหนดเอง
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-04-14 UTC
[[["เข้าใจง่าย","easyToUnderstand","thumb-up"],["แก้ปัญหาของฉันได้","solvedMyProblem","thumb-up"],["อื่นๆ","otherUp","thumb-up"]],[["ไม่มีข้อมูลที่ฉันต้องการ","missingTheInformationINeed","thumb-down"],["ซับซ้อนเกินไป/มีหลายขั้นตอนมากเกินไป","tooComplicatedTooManySteps","thumb-down"],["ล้าสมัย","outOfDate","thumb-down"],["ปัญหาเกี่ยวกับการแปล","translationIssue","thumb-down"],["ตัวอย่าง/ปัญหาเกี่ยวกับโค้ด","samplesCodeIssue","thumb-down"],["อื่นๆ","otherDown","thumb-down"]],["อัปเดตล่าสุด 2025-04-14 UTC"],[[["To extend an existing Blockly field, subclass a built-in field like `FieldTextInput` or `FieldColour` and modify its editor, on-block display, or displayed text."],["For custom fields with unique behaviors, subclass the base `Field` class instead of extending an existing field."],["Common field extensions involve customizing text input (`FieldTextInput`), numbers (`FieldNumber`), or dropdowns (`FieldDropdown`) to meet specific needs."],["When subclassing, ensure your constructor matches the super-constructor's signature and register the field with `Blockly.fieldRegistry.register`."],["Implement the `fromJson` method in your custom field class to enable compatibility with the Blockly JSON format for serialization and deserialization."]]],["To extend an existing field, subclass a built-in field like `FieldTextInput` or `FieldColour`, modifying its editor, on-block display, or text. For unique fields, subclass `Field`. Common extensions include `FieldTextInput`, `FieldNumber`, and `FieldDropdown`. Subclass constructors should mirror the super-constructor's signature. Register the field using `Blockly.fieldRegistry.register()` and implement `fromJson` for JSON compatibility. Extending different fields such as `FieldLabelSerializable` is also possible.\n"]]