透過集合功能整理內容
你可以依據偏好儲存及分類內容。
封鎖 >變數 >createVariableButtonHandler
處理「建立變數」按鈕,系統會提示使用者輸入變數名稱,包括如果工作區變數中已有人使用某個名稱,便會重新顯示提示。
自訂按鈕處理常式可以委派給這個函式,允許變數類型並在建立後進行處理。複雜自訂項目 (例如針對變數類型的提示) 不屬於這個函式。
Signature:
export declare function createVariableButtonHandler(workspace: Workspace, opt_callback?: (p1?: string | null) => void, opt_type?: string): void;
參數
參數 |
類型 |
說明 |
工作區 |
Workspace |
要建立變數的工作區。 |
opt_callback |
(p1?: string | null) =>void |
(選用) 回呼。會傳送可接受的新變數名稱;如果變更要取消 (取消按鈕),則會傳遞空值;如選擇現有變數,則傳回未定義。 |
opt_type |
字串 |
(選用) 變數的類型,例如「int」、「string」或「'」。預設為 '',此為特定類型。 |
傳回:
void
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2024-09-09 (世界標準時間)。
[[["容易理解","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"]],["上次更新時間: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."]]],[]]