用户与对象树的交互可通过xml格式的配置文件进行设置,支持的交互方式包括右键菜单、双击事件(DblClickEvent)、拖拽事件(DropEvent)等。
配置文件规范
<context>
<node type="Document" icon="icons/tree/1-2Prj.png" />
<node type="XCoordSys">
<action text="编辑" cid="CoordSystem" icon="icons/file_new.png"/>
</node>
<catagory type="Analysis">
<node type="AnaNastran" icon="icons/tree/14-2Analysis.png" dragable="true" dropable="true">
<menu text="插入" cid="0" icon="icons/file_new.png">
<action text="温度" cid="ConstTemperature" icon="icons/file_new.png"/>
</menu>
<action text="删除" cid="DeleteItem" icon="icons/file_open.png"/>
<action text="::DropEvent" cid="ReferAnalysis" />
</node>
</category>
</context>
关键字
| 关键字 | 说明 | xml标签 |
|---|---|---|
| 节点 | 与对象树节点对应 | node |
| 目录 | 将节点按目录分类,便于理解、编辑 | category |
| 菜单 | 对应右键菜单 | menu |
| 动作 | 交互命令 | action |
事件
事件以Action的属性给定,格式为event=“::<EventName>”, 其中<EventName>在下表中的xml标签列出
| 事件 | xml标签 |
|---|---|
| 双击事件 | DblClickEvent |
| 拖拽事件 | DropEvent |
属性关键字
| 关键字 | 说明 | 示例 |
|---|---|---|
| type | 对象类型,字符串,一般在源码中(注册对象时)定义 | type=“XCoordSys” |
| cid | 动作对应的命令名,字符串,在源码中(注册命令时)定义 | cid=“DeleteItem” |
| text | 显示字符串 | text=“删除” |
| icon | 显示图标路径,字符串,以资源目录根目录的相对路径 | icon=“icons/file_open.png” |