研究调查问卷:请告诉我们您使用 Blockly 的体验
开始调查问卷
blockly >变量 >createVariableButtonHandler
处理“创建变量”按钮。它会提示用户输入变量名称,包括在工作区变量中已有人使用该名称时再次提示。
自定义按钮处理程序可以委托给此函数,以便允许变量类型和创建后处理。更复杂的自定义(例如提示变量类型)超出了此函数的范围。
Signature:
export declare function createVariableButtonHandler(workspace: Workspace, opt_callback?: (p1?: string | null) => void, opt_type?: string): void;
参数
参数 |
类型 |
说明 |
工作区 |
Google Workspace |
要在其中创建变量的工作区。 |
opt_callback |
(p1?: string | null) =>无效 |
(可选)回调。系统会向其传递可接受的新变量名称;如果要取消更改(取消按钮),则为 null;如果已选择现有变量,则传递 undefined。 |
opt_type |
字符串 |
(可选)变量的类型,例如“int”、“string”或“”。默认为 '',这是一个特定类型。 |
返回:
void
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2024-09-09。
[null,null,["最后更新时间 (UTC):2024-09-09。"],[[["`createVariableButtonHandler` facilitates the creation of new variables within a Blockly workspace, managing user prompts for variable names and handling potential naming conflicts."],["This function can be used by custom button handlers, offering flexibility for defining variable types and incorporating post-creation actions."],["While offering basic variable creation functionality, `createVariableButtonHandler` is not designed for complex customizations like prompting for variable type."],["The function takes the workspace, an optional callback for processing the new variable name, and an optional variable type as parameters."]]],[]]