赞
踩
乐吾乐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"],
- };
- meta2d.addPen(pen);
生命周期函数类型均为:(pen: Pen) => void , 除了 onBeforeValue, onChangeId
其他相关函数:
- const onAddPen = (pen: Pen) => {
- console.log("onAddPen", pen);
- };
-
- // 定义一个pen,矩形
- const pen = {
- name: "rectangle",
- text: "矩形",
- x: 100,
- y: 100,
- width: 100,
- height: 100,
- onAdd: onAddPen,
- };
- meta2d.addPen(pen);
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。