blockly > 变量 > createVariableButtonHandler

Variables.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) => void (可选)回调。它会传递一个可接受的新变量名称;如果要取消更改(取消按钮),则为 null,如果是选择现有变量,则传递 undefined。
opt_type string (可选)变量的类型,例如“int”“string”或“”。默认值为“'”,这是一种特定类型。

返回

void