classMyInputextendsBlockly.inputs.Input{// The constructor should always take in a name and a block to be compatible// with JSON block definitions.constructor(name,block){super(name,block);// etc...}}
[null,null,["最后更新时间 (UTC):2025-07-25。"],[[["\u003cp\u003eSubclass \u003ccode\u003eBlockly.inputs.Input\u003c/code\u003e to create a custom input, ensuring the constructor accepts a name and block for JSON compatibility.\u003c/p\u003e\n"],["\u003cp\u003eOptionally create a connection for the input using the \u003ccode\u003emakeConnection\u003c/code\u003e method within the constructor.\u003c/p\u003e\n"],["\u003cp\u003eRegister the custom input with \u003ccode\u003eBlockly.registry\u003c/code\u003e to enable its usage in JSON block definitions, associating it with a unique string identifier.\u003c/p\u003e\n"],["\u003cp\u003eCustom inputs cannot replace built-in inputs, nor can custom JSON configuration be added to built-in inputs.\u003c/p\u003e\n"]]],["To create a custom input, subclass the `Input` class, including a constructor that accepts a name and block. Optionally, create a connection within the constructor using the `makeConnection` method. To use the custom input in JSON block definitions, register it with `Blockly.registry.register`, associating it with a unique string. Note that unlike custom fields, built-in inputs cannot be overridden and do not accept custom JSON configurations.\n"],null,["# Create custom inputs\n\nTo create a custom input, you need to subclass [`Input`](/blockly/reference/js/blockly.inputs_namespace.input_class), or one of\nits subclasses. \n\n class MyInput extends Blockly.inputs.Input {\n\n // The constructor should always take in a name and a block to be compatible\n // with JSON block definitions.\n constructor(name, block) {\n super(name, block);\n // etc...\n }\n }\n\nOptionally create a connection\n------------------------------\n\nIf you want your input to have a connection, that should be created in the\nconstructor, by calling the [`makeConnection`](/blockly/reference/js/blockly.inputs_namespace.input_class.makeconnection_1_method) method. \n\n constructor(name, block) {\n super(name, block);\n\n this.connection = this.makeConnection(ConnectionType.INPUT_VALUE);\n }\n\nRegister the input\n------------------\n\nTo be able to use your custom input in a [JSON block definition](/blockly/guides/create-custom-blocks/define/json-and-js)\nyou need to register it and associate it with a string. \n\n class MyInput extends Blockly.inputs.Input {}\n\n Blockly.registry.register(Blockly.registry.Type.INPUT, 'my_input', MyInput);\n\n| **Note:** unlike [custom fields](/blockly/guides/create-custom-blocks/fields/customizing-fields/creating), you can't override built-in inputs, and you can't add custom JSON configuration to them."]]