customPlus动态添加按钮,滚动条滚动不了(附代码,已解决)

niheibie 1月前 411

Code AardioLine:71复制
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.
  • 39.
  • 40.
  • 41.
  • 42.
  • 43.
  • 44.
  • 45.
  • 46.
  • 47.
  • 48.
  • 49.
  • 50.
  • 51.
  • 52.
  • 53.
  • 54.
  • 55.
  • 56.
  • 57.
  • 58.
  • 59.
  • 60.
  • 61.
  • 62.
  • 63.
  • 64.
  • 65.
  • 66.
  • 67.
  • 68.
  • 69.
  • 70.
  • 71.
    • import win.ui;
    • /*DSG{{*/
    • var winform = win.form(text="aardio form";right=711;bottom=407)
    • winform.add(
    • button={cls="button";text="添加";left=488;top=328;right=690;bottom=388;color=14120960;flat=1;font=LOGFONT(h=-14);note="添加一个项目";z=2};
    • plus={cls="plus";left=0;top=0;right=688;bottom=320;clipBk=false;edge=1;notify=1;z=1};
    • scrollbar={cls="scrollbar";left=688;top=0;right=708;bottom=320;edge=1;z=3}
    • )
    • /*}}*/
    • winform.show();
    • import inet.http
    • // 定义项目模板
    • var itemModel = {
    • {
    • type="rect",
    • rectf={x=3;y=3;width=-3;height=-3},
    • name="项目背景色",
    • click=true;
    • width=2,
    • round=4,
    • color=0xFF009955,
    • fillcolor=0x55009955,
    • hoverfillcolor=0xBB009955,
    • },
    • {
    • type="text",
    • rectf={x=3;y=3;width=-3;height=-3},
    • name="标题文字",
    • align=1;
    • valign=1;
    • smooth=true;
    • text="",
    • font={name="Tahoma",h=-13,color=0xFFFFFFFF,weight=700},
    • hoverfont={name="Tahoma",h=-16,color=0xFFFFFF00,weight=700},
    • }
    • }
    • //生成项目列表
    • var itemList = {}
    • for(i=1;40;1){
    • ..table.push(itemList,{标题文字="ITEM"++i})
    • }
    • //构造组件
    • import godking.customPlus
    • var c = godking.customPlus(winform.plus,itemModel,itemList,{
    • itemWidth=80, /*项目宽度*/
    • itemHeight=40, /*项目高度*/
    • autoSizeWidth=1, /*自动根据项目行数及plus高度调整项目高度*/
    • autoSizeHeight=1, /*自动根据项目列数及plus宽度调整项目宽度*/
    • colnum=0, /*项目列数,为0则根据项目宽度和plus宽度自动计算*/
    • rownum=0, /*项目行数,为0则根据项目高度和plus高度自动计算*/
    • padLeft=20, /*plus左边空白距离*/
    • padTop=20, /*plus顶边空白距离*/
    • padRight=20, /*plus右边空白距离*/
    • padBottom=20, /*plus底边空白距离*/
    • bkimg = "https://img1.baidu.com/it/u=3977836567,3094831983&fm=253&fmt=auto&app=138&f=JPEG?w=750&h=500"
    • });
    • c.onClick = function(itemIndex){
    • ..win.msgbox("您点击了:"++itemIndex)
    • }
    • winform.button.oncommand = function(id,event){
    • c.addItem({标题文字="ITEM"++(#itemList+1)})
    • c.update()
    • }
    • c.bindScrollbar(winform.scrollbar);
    • win.loopMessage();


    // 点击添加按钮超出范围后,, 滚动条滚动不了.. 

    已修改,升级新版customPlus库,功能可正常使用。

    最新回复 (4)
    • 光庆 1月前
      0 2
      Code AardioLine:5复制
    • 1.
    • 2.
    • 3.
    • 4.
    • 5.
      • winform.button.oncommand = function(id,event){
      • ..table.push(itemList,{标题文字="ITEM"++(#itemList+1)})
      • c.update()
      • c.bindScrollbar(winform.scrollbar)
      • }


    • niheibie 22天前
      0 3
      光庆 winform.button.oncommand = function(id,event){    & ...
      鼠标滚轮的话有bug,你复制代码去试试就知道了
    • 光庆 22天前
      0 4
      niheibie 鼠标滚轮的话有bug,你复制代码去试试就知道了
      已升级,请更新库文件。
    • niheibie 19天前
      0 5
      光庆 已升级,请更新库文件。
      感谢
    返回