blockly > Toolbox

Toolbox 類別

Toolbox 的類別。建立工具箱的 DOM。

Signature:

export declare class Toolbox extends DeleteArea implements IAutoHideable, IKeyboardAccessible, IStyleable, IToolbox, IFocusableNode 

Extends: DeleteArea

實作: IAutoHideableIKeyboardAccessibleIStyleableIToolboxIFocusableNode

建構函式

建構函式 修飾符 說明
(constructor)(workspace) 建構 Toolbox 類別的新例項

屬性

屬性 修飾符 類型 說明
boundEvents_ protected browserEvents.Data[] 陣列,可保留解除事件處理常式所需的資訊。用於處置。例如:[[node, name, func], [node, name, func]]。
內容 protected Map<string, IToolboxItem> 將 ID 對應至對應的工具箱項目。
contentsDiv_ protected HTMLDivElement | null 工具箱內容的 HTML 容器。
height_ protected 數字 工具箱的高度。
HtmlDiv HTMLDivElement | null 工具箱的 HTML 容器。
id 字串 這個元件專屬的 ID,用於向 ComponentManager 註冊。
isVisible_ protected 布林值 是否顯示工具箱。
previouslySelectedItem_ protected ISelectableToolboxItem | null 先前選取的項目。
RTL 布林值
selectedItem_ protected ISelectableToolboxItem | null 目前選取的項目。
toolboxDef_ protected toolbox.ToolboxInfo
toolboxPosition toolbox.Position
width_ protected 數字 工具箱的寬度。
workspace_

protected

readonly

WorkspaceSvg 這個工具箱所在的工作區。

方法

方法 修飾符 說明
addToolboxItem_(toolboxItem) protected 將項目新增至工具箱。
attachEvents_(container, contentsContainer) protected 將事件監聽器新增至工具箱容器 div。
autoHide(onlyClosePopups) 隱藏元件。在 WorkspaceSvg.hideChaff 中呼叫。
canBeFocused() 請參閱 IFocusableNode.canBeFocused。
clearSelection() 取消醒目顯示先前選取的項目。
createContainer_() protected 建立工具箱的容器 div。
createContentsContainer_() protected 為工具箱中的所有內容建立容器。
createDom_(workspace) protected 建立工具箱的 DOM。
createFlyout_() protected 根據工具箱版面配置建立彈出式視窗。
deselectItem_(item) protected 取消選取指定項目、將其標示為未選取,並更新 aria 狀態。
dispose() 處置這個工具箱。
getClientRect() 傳回拖曳目標區域的邊界矩形,以相對於可視區域的像素單位為單位。
getFlyout() 取得工具箱彈出式視窗。
getFocusableElement() 請參閱 IFocusableNode.getFocusableElement。
getFocusableTree() 請參閱 IFocusableNode.getFocusableTree。
getHeight() 取得工具箱的高度。
getNestedTrees() 請參閱 IFocusableTree.getNestedTrees。
getPreviouslySelectedItem() 取得先前選取的項目。
getRestoredFocusableNode(previousNode) 請參閱 IFocusableTree.getRestoredFocusableNode。
getRootFocusableNode() 請參閱 IFocusableTree.getRootFocusableNode。
getSelectedItem() 取得所選項目。
getToolboxItemById(id) 取得具有指定 ID 的工具箱項目。
getToolboxItems() 取得工具箱中的項目。
getWidth() 取得工具箱的寬度。
getWorkspace() 取得工具箱的工作區。
init() 初始化工具箱
isHorizontal() 取得工具箱是否為水平。
lookUpFocusableNode(id) 請參閱 IFocusableTree.lookUpFocusableNode。
onClick_(e) protected 處理工具箱或工具箱項目點擊事件。
onDragEnter(_dragElement) 當含有區塊或氣泡的游標進入此拖曳目標時,會處理此事件。
onDragExit(_dragElement) 當游標含有方塊或氣泡並離開此拖曳目標時,此方法會處理相關事件。
onDrop(_dragElement) 在這個元件上放置區塊或氣泡時處理。不應在此處處理刪除作業。
onKeyDown_(e) protected 處理工具箱的按鍵按下事件。
onNodeBlur() 請參閱 IFocusableNode.onNodeBlur。
onNodeFocus() 請參閱 IFocusableNode.onNodeFocus。
onShortcut(_shortcut) 處理指定的鍵盤快速鍵。
onTreeBlur(_nextTree) 請參閱 IFocusableTree.onTreeBlur。
onTreeFocus(node, _previousTree) 請參閱 IFocusableTree.onTreeFocus。
position() 根據工具箱是否為水平工具箱,以及工作區是否為 RTL,來決定工具箱的位置。
refreshSelection() 更新彈出式視窗的內容,但不關閉彈出式視窗。應在回應動態類別 (例如變數或程序) 的變更時使用。
renderContents_(toolboxDef) protected 將所有工具箱項目新增至工具箱。
selectItem_(oldItem, newItem) protected 選取指定項目、標示為已選取,並更新 aria 狀態。
selectItemByPosition(position) 根據工具箱項目清單中的順序選取工具箱項目。
setSelectedItem(newItem) 將指定項目設為已選取。如果項目無法選取,則不執行任何操作。
setVisible(isVisible) 顯示或隱藏工具箱。
shouldDeselectItem_(oldItem, newItem) protected 決定是否應取消選取舊項目。
shouldSelectItem_(oldItem, newItem) protected 決定是否應選取新項目。
updateCursorDeleteStyle_(addStyle) protected 根據工具箱上方游標的 CSS 樣式,新增或移除游標 (使用內部 this.wouldDelete_ 屬性),以便在游標移除時刪除上方區塊或氣泡。
updateFlyout_(oldItem, newItem) protected 根據所選項目決定是否隱藏或顯示彈出式選單。
updateWouldDelete_(wouldDelete) protected 更新內部 wouldDelete_ 狀態。
wouldDelete(element) 傳回是否會在將提供的區塊或氣泡放到這個區域時刪除。此方法應檢查元素是否可刪除,且一律會在 onDragEnter/onDragOver/onDragExit 之前呼叫。