生命周期
乐吾乐2D可视化组态编辑器demo:https://2d.le5le.com/
全局生命周期函数
meta2d.beforeAddPens = async (pens: Pen[]) => {
console.log("addPens", pens);
// showDialog 伪代码
const res = await showDialog("是否添加此图元?");
// 返回 true 允许 remove
return res.ok;
};
// 删除组合节点时, beforeRemovePens 会多次触发
meta2d.beforeRemovePens = async (pens: Pen[]) => {
console.log("removePens", pens);
// showDialog 伪代码
const res = await showDialog("是否删除所选图元?");
// 返回 true 允许 remove
return res.ok;
};
meta2d.beforeAddAnchor = async (pen: Pen, anchor: Point) => {
// showDialog 伪代码
return await showModal("添加锚点");
};
meta2d.beforeRemoveAnchor = async (pen: Pen, anchor: Point) => {
// showDialog 伪代码
return await showModal("删除锚点");
};
// 定义一个pen,矩形
const pen = {
name: "rectangle",
text: "矩形",
x: 100,
y: 100,
width: 100,
height: 100,
tag: ["aaa"]