blockly > 工具箱

Toolbox 类

用于工具箱的类。创建工具箱的 DOM。

Signature:

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

扩展DeleteArea

实现IAutoHideableIKeyboardAccessibleIStyleableIToolbox

构造函数

构造函数 修饰符 说明
(构造函数)(工作区) 构造 Toolbox 类的新实例

属性

属性 修饰符 类型 说明
boundEvents_ protected browserEvents.Data[] 包含解除绑定事件处理脚本所需的信息的数组。用于处置。例如:[[node, name, func], [node, name, func]]。
contentMap_ protected { [key: string]: IToolboxItem; }
contents_ protected IToolboxItem[] 工具箱中的项目列表。
contentsDiv_ protected HTMLDivElement | null 工具箱内容的 HTML 容器。
height_ protected number 工具箱的高度。
HtmlDiv HTMLDivElement | null 工具箱的 HTML 容器。
ID [id] string 用于向 ComponentManager 注册的此组件的唯一 ID。
isVisible_ protected boolean 工具箱是否可见。
previouslySelectedItem_ protected ISelectableToolboxItem | null 之前选择的项。
RTL boolean
selectedItem_ protected ISelectableToolboxItem | null 当前所选项。
toolboxDef_ protected toolbox.ToolboxInfo
toolboxPosition toolbox.Position
width_ protected number 工具箱的宽度。
workspace_

protected

readonly

WorkspaceSvg 此工具箱所在的工作区。

方法

方法 修饰符 说明
addToolboxItem_(toolboxItem) protected 向工具箱添加项。
attachEvents_(container, 内容分级) protected 向工具箱容器 div 添加事件监听器。
autoHide(onlyClosePopups) 隐藏组件。在 WorkspaceSvg.hideChaff 中调用了此 API。
clearSelection() 取消突出显示之前选择的任何项。
createContainer_() protected 为工具箱创建容器 div。
createContentsContainer_() protected 为工具箱中的所有内容创建容器。
createDom_(workspace) protected 为工具箱创建 DOM。
createFlyout_() protected 根据工具箱布局创建浮出控件。
deselectItem_(item) protected 取消选择给定项,将其标记为未选中,并更新 aria 状态。
dispose() 处置此工具箱。
getClientRect() 返回拖动目标区域的边界矩形(以像素为单位),相对于视口。
getFlyout() 获取工具箱浮出控件。
getHeight() 获取工具箱的高度。
getPreviouslySelectedItem() 获取之前选定的项。
getSelectedItem() 获取所选商品。
getToolboxItemById(id) 获取具有指定 ID 的工具箱项。
getToolboxItems() 获取工具箱中的项。
getWidth() 获取工具箱的宽度。
getWorkspace() 获取工具箱的工作区。
init() 初始化工具箱
isHorizontal() 获取工具箱是否处于水平状态。
onClick_(e) protected 在用户点击工具箱或工具箱项时处理点击事件。
onDragEnter(_dragElement) 处理带有块或气泡的光标进入此拖动目标的情况。
onDragExit(_dragElement) 处理带有块或气泡的光标离开此拖动目标的情况。
onDrop(_dragElement) 处理在此组件上拖放块或气泡的情况。不应在此处处理删除操作。
onKeyDown_(e) protected 处理工具箱的按键按下事件。
onShortcut(_shortcut) 处理指定的键盘快捷键。
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.DisallowDelete_ 属性)。
updateFlyout_(oldItem, newItem) protected 根据所选项决定是隐藏还是显示浮出控件。
updateWouldDelete_(wouldDelete) protected 更新内部 wouldDelete_ 状态。
wouldDelete(element) 返回如果将提供的方块或气泡放到此区域,是否会被删除。此方法应检查元素是否可删除,并且始终会在 onDragEnter/onDragOver/onDragExit 之前调用。