Blockly가 2025년 11월 10일에 Raspberry Pi Foundation으로 이전되었습니다. 블로그 게시물과 FAQ를 읽어보세요.
Google uses AI technology to translate content into your preferred language. AI translations can contain errors.
기존 필드 확장
컬렉션을 사용해 정리하기
내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
기존 필드를 확장하려면 기본 제공 필드 (예:
FieldTextInput, FieldColour)을 사용하여 필요에 맞게 일부를 수정할 수 있습니다.
다음은 수정할 수 있는 필드의 일부입니다.
광고주의
커스텀 필드
기본 제공 필드에서 동작이 필요하지 않은 경우 Field의 서브클래스를 생성해야 합니다.
일반적인 확장 프로그램
대부분의 맞춤 필드는 다음 세 가지 유형 중 하나를 확장합니다.
- 텍스트 입력: 사용자가 입력란에 입력하도록 하려면
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 MyCustomTextField(value);
}
필드 등록에 대한 자세한 내용은 JSON 및 등록을 참조하세요.
섹션을 참조하세요.
달리 명시되지 않는 한 이 페이지의 콘텐츠에는 Creative Commons Attribution 4.0 라이선스에 따라 라이선스가 부여되며, 코드 샘플에는 Apache 2.0 라이선스에 따라 라이선스가 부여됩니다. 자세한 내용은 Google Developers 사이트 정책을 참조하세요. 자바는 Oracle 및/또는 Oracle 계열사의 등록 상표입니다.
최종 업데이트: 2025-08-20(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-08-20(UTC)"],[],["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"]]