vivienluo 发表于 2013-5-3 23:35:42

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

在每个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

下面是一个简单的菜单例子:axlCmdRegister( "popuptest" 'popuptest ?cmdType "interactive")      
procedure(popuptest()
      notdone = t
      
      popTest = axlUIPopupDefine(nil (list
      (list "Button 1" 'poppBP1 )
      (list "Button 2" 'poppBP2 )
      (list "Button 3" 'poppBP3 )
      (list "Exit" 'poppBPE ))
      )
      axlUIPopupSet(popTest)
      while( notdone
      axlSingleSelectPoint()
      );end while
)      
procedure(poppBP1()
      axlUIConfirm("You have pressed Button 1")
      notdone = nil
);end procedure
procedure(poppBP2()
      axlUIConfirm("You have pressed Button 2")
      notdone = nil
);end procedure
procedure(poppBP3()
      axlUIConfirm("You have pressed Button 3")
      notdone = nil
);end procedure

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

显示效果为:








zxg1113 发表于 2013-5-4 11:22:01

不错,我去试试

wuyuhe 发表于 2014-4-15 11:09:05

不错不错,我去尝试一下~

owencai 发表于 2014-5-29 17:10:43

学习了,谢谢啊!

chuchiwolong 发表于 2014-6-18 10:33:28

非常感谢!

墨客的秋天 发表于 2014-11-23 22:52:13

感谢分享,谢谢楼主,下下来看看

22587953@qq.com 发表于 2014-12-4 16:54:35

不做,谢谢分享

kingsogo 发表于 2014-12-8 16:30:33

:):):):):):)

PKN1216083420 发表于 2015-1-12 15:13:59

赞一个,非常感谢

PKN1216083420 发表于 2015-1-12 15:15:15

赞一个,非常感谢!
页: [1] 2 3 4
查看完整版本: 教你如何使用SKILL自定义右键菜单