在线咨询
eetop公众号 创芯大讲堂 创芯人才网
切换到宽版

EETOP 创芯网论坛 (原名:电子顶级开发网)

手机号码,快捷登录

手机号码,快捷登录

找回密码

  登录   注册  

快捷导航
搜帖子
查看: 627|回复: 15

[求助] 求助hiCreateComboField callback

[复制链接]
发表于 2024-5-29 10:43:11 | 显示全部楼层 |阅读模式
200资产
请教大佬,为什么下面的代码callback功能可以实现,但是在OK Apply cancel 的 时候不能关掉窗口

                               
登录/注册后可看大图





  1. procedure(testSelectCV()
  2. let((lib cell view)
  3.     lib = hiCreateComboField(
  4.         ?name 'lib
  5.         ?prompt "lib"
  6.         ?items ddGetLibList()~>name
  7.         ?callback "testSelectCV_SelCB(hiGetCurrentForm() "lib")"
  8.     )
  9.     cell = hiCreateComboField(
  10.         ?name 'cell
  11.         ?prompt "cell"
  12.         ?callback "testSelectCV_SelCB(hiGetCurrentForm() "cell")"
  13.     )
  14.     view = hiCreateComboField(
  15.         ?name 'view
  16.         ?prompt "view"
  17.         ?callback ""
  18.     )
  19.     testSelectForm = hiCreateAppForm(
  20.         ?name 'testSelectForm
  21.         ?formTitle "testSelectForm"
  22.         ?fields list(
  23.             1ist(lib 10:10 200:30 60)
  24.             1ist(cell 10:50 200:30 60)
  25.             1ist(view 10:90 200:30 60)
  26.         );end fields
  27.     );end create app form
  28.     hiDisplayForm('testSelectForm)
  29.     t);end let
  30. );end proc

  31. procedure(testSelectCV_SelCB(form \@optional field("lib"))
  32. let((cells currentCell views currentView)
  33.     cond(
  34.         (field == "lib"                ;;Control cell field
  35.             currentCell = form->cell->value
  36.             unless(currentCell
  37.                 cells = ddGetObj(form->lib->value)->cells~>name
  38.                 form->cell->items = cells
  39.                 form->cell->value = car(cells)
  40.             );end unless
  41.             when(currentCell
  42.                 cells = ddGetObj(form->lib->value)->cells~>name
  43.                 form->cell->items = cells
  44.                 unless(member(currentCell cells)
  45.                     form->cell->value = car(cells)
  46.                 );end unless
  47.             );end when
  48.         )
  49.         (field == "cell"        ;;Control view field
  50.             currentView = form->view->value
  51.             unless(currentView
  52.                 views = ddGetObj(form->lib->value form->cell->value)->views~>name
  53.                 form->view->items = views
  54.                 form->view->value = car(views)
  55.             );end unless
  56.             when(currentView
  57.                 views = ddGetObj(form->lib->value form->cell->value)->views~>name
  58.                 form->view->items = views
  59.                 unless(member(currentView views)
  60.                     form->view->value = car(views)
  61.                 );end unless
  62.             );end when
  63.         )
  64.     );end cond
  65.     t
  66.     );end let
  67. );end proc


复制代码



发表于 2024-5-29 11:31:53 | 显示全部楼层
虽然没看完,但string里面加双引号你不加反斜杠\吗
 楼主| 发表于 2024-5-29 13:06:30 | 显示全部楼层


着着着火了 发表于 2024-5-29 11:31
虽然没看完,但string里面加双引号你不加反斜杠\吗


这个是我弄出来没加上的问题,我测试的是加上的
 楼主| 发表于 2024-5-29 13:07:56 | 显示全部楼层
本帖最后由 YuSHL 于 2024-5-29 15:10 编辑

我copy过来是加上的

procedure(testSelectCV()
let((lib cell view)
    lib = hiCreateComboField(
        ?name 'lib
        ?prompt "lib"
        ?items ddGetLibList()~>name
        ?callback "testSelectCV_SelCB(hiGetCurrentForm() \"lib\")"
    )
    cell = hiCreateComboField(
        ?name 'cell
        ?prompt "cell"
        ?callback "testSelectCV_SelCB(hiGetCurrentForm() \"cell\")"
    )
    view = hiCreateComboField(
        ?name 'view
        ?prompt "view"
        ?callback ""
    )
    testSelectForm = hiCreateAppForm(
        ?name 'testSelectForm
        ?formTitle "testSelectForm"
        ?fields list(
            list(lib 10:10 200:30 60)
            list(cell 10:50 200:30 60)
            list(view 10:90 200:30 60)
        );end fields
    );end create app form
    hiDisplayForm('testSelectForm)
    t);end let
);end proc

procedure(testSelectCV_SelCB(form \@optional field("lib"))
let((cells currentCell views currentView)
    cond(
        (field == "lib"                ;;Control cell field
            currentCell = form->cell->value
            unless(currentCell
                cells = ddGetObj(form->lib->value)->cells~>name
                form->cell->items = cells
                form->cell->value = car(cells)
            );end unless
            when(currentCell
                cells = ddGetObj(form->lib->value)->cells~>name
                form->cell->items = cells
                unless(member(currentCell cells)
                    form->cell->value = car(cells)
                );end unless
            );end when
        )
        (field == "cell"        ;;Control view field
            currentView = form->view->value
            unless(currentView
                views = ddGetObj(form->lib->value form->cell->value)->views~>name
                form->view->items = views
                form->view->value = car(views)
            );end unless
            when(currentView
                views = ddGetObj(form->lib->value form->cell->value)->views~>name
                form->view->items = views
                unless(member(currentView views)
                    form->view->value = car(views)
                );end unless
            );end when
        )
    );end cond
    t
    );end let
);end proc

 楼主| 发表于 2024-5-29 13:09:20 | 显示全部楼层


着着着火了 发表于 2024-5-29 11:31
虽然没看完,但string里面加双引号你不加反斜杠\吗


用代码块的方式上传到这就没了
发表于 2024-5-29 15:32:48 | 显示全部楼层


YuSHL 发表于 2024-5-29 13:09
用代码块的方式上传到这就没了


apply本来就不能关闭,测试下来点OK和cancel都能关闭
 楼主| 发表于 2024-5-29 15:44:11 | 显示全部楼层


着着着火了 发表于 2024-5-29 15:32
apply本来就不能关闭,测试下来点OK和cancel都能关闭


选择之后lib cell view之后能关掉吗?

发表于 2024-5-29 16:37:06 | 显示全部楼层


YuSHL 发表于 2024-5-29 15:44
选择之后lib cell view之后能关掉吗?



 楼主| 发表于 2024-5-29 17:20:56 | 显示全部楼层


是直接用我贴上的代码吗?为什么我这边会报上面图中的error
发表于 2024-5-29 18:11:36 | 显示全部楼层


YuSHL 发表于 2024-5-29 17:20
是直接用我贴上的代码吗?为什么我这边会报上面图中的error


是用你上面的代码,没改。

我测试的时候报错只会发生在选了lib之后,然后点cancel,这时候触发field的callback(按理来说不会有动作才对),因为你的代码写的是ddGetObj(form->lib->value),这时候form已经被关闭了,所以form为nil,这一串都为nil,所以就出现了ddGetObj(nil)这个问题,也就是报出来的error
您需要登录后才可以回帖 登录 | 注册

本版积分规则

关闭

站长推荐 上一条 /2 下一条

×

小黑屋| 手机版| 关于我们| 联系我们| 在线咨询| 隐私声明| EETOP 创芯网
( 京ICP备:10050787号 京公网安备:11010502037710 )

GMT+8, 2024-9-23 02:43 , Processed in 0.022321 second(s), 7 queries , Gzip On, Redis On.

eetop公众号 创芯大讲堂 创芯人才网
快速回复 返回顶部 返回列表