Cadence Skill 论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 28062|回复: 35

教你如何使用SKILL自定义右键菜单

[复制链接]
发表于 2013-5-3 23:35:42 | 显示全部楼层 |阅读模式
在每个SKILL编程中,右键菜单是经常使用到的。下面就如何添加自定义右键菜单做一个简单介绍。

需要用到的axl函数
     axlUIPopupDefine,用于定义右键菜单的各个选项;
     axlUIPopupSet,将定义好的菜单设置到右键中。
     
axlUIPopupDefine函数结构如下:
    axlUIPopupDefine(    r_popup
   ts_pairs
   )

⇒ r_popup/nil
第一个参数 r_popup 为之前存在的菜单handle ,如果创建新的菜单,那么这个参数为 nil

第二个为菜单的项目。注意使用list来定义。一般结构为((“菜单名”  需要调用的函数)

axlUIPopupDefine函数定义菜单成功后会返回一个菜单ID

axlUIPopupSet函数结构如下:
axlUIPopupSet(
r_popup
)
⇒ t/nil
其传递参数为定义菜单的ID,可通过获取axlUIPopupDefine函数的返回值来确定具体ID

下面是一个简单的菜单例子:
  1. axlCmdRegister( "popuptest" 'popuptest ?cmdType "interactive")        
  2. procedure(popuptest()
  3.         notdone = t
  4.         
  5.         popTest = axlUIPopupDefine(nil (list
  6.         (list "Button 1" 'poppBP1 )
  7.         (list "Button 2" 'poppBP2 )
  8.         (list "Button 3" 'poppBP3 )
  9.         (list "Exit" 'poppBPE ))
  10.         )
  11.         axlUIPopupSet(popTest)
  12.         while( notdone
  13.         axlSingleSelectPoint()
  14.         );end while
  15. )        
  16. procedure(poppBP1()
  17.         axlUIConfirm("You have pressed Button 1")
  18.         notdone = nil
  19. );end procedure
  20. procedure(poppBP2()
  21.         axlUIConfirm("You have pressed Button 2")
  22.         notdone = nil
  23. );end procedure
  24. procedure(poppBP3()
  25.         axlUIConfirm("You have pressed Button 3")
  26.         notdone = nil
  27. );end procedure

  28. procedure(poppBPE()
  29.         axlUIConfirm("You have pressed Exit")
  30.         notdone = nil
  31. );end procedure
复制代码
当每次点击任何个菜单项时,会弹出相应的对话框。

显示效果为:

popup.png

popup_test.rar (662 Bytes, 下载次数: 125)
发表于 2013-5-4 11:22:01 | 显示全部楼层
不错,我去试试
发表于 2014-4-15 11:09:05 | 显示全部楼层
不错不错,我去尝试一下~
发表于 2014-5-29 17:10:43 | 显示全部楼层
学习了,谢谢啊!
发表于 2014-6-18 10:33:28 | 显示全部楼层
非常感谢!
发表于 2014-11-23 22:52:13 | 显示全部楼层
感谢分享,谢谢楼主,下下来看看
发表于 2014-12-4 16:54:35 | 显示全部楼层
不做,谢谢分享
发表于 2015-1-12 15:13:59 | 显示全部楼层
赞一个,非常感谢
发表于 2015-1-12 15:15:15 | 显示全部楼层
赞一个,非常感谢!
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|网站地图|Cadence Skill 论坛 ( 蜀ICP备13024417号 )

GMT+8, 2024-4-25 01:55 , Processed in 0.156668 second(s), 20 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表