选择所有inDCL列表框p
下午好,如果我错过了一些简单的事情,请道歉。我在DCL对话框中有一个列表框,我想创建一个按钮来选择列表中的所有项目。我找到了一个解决方案,它突出显示了所有列表,但如果有意义的话,它似乎不会选择它们。只是想知道我哪里出错了。
由于我从其他来源复制了这篇文章的一部分,在我完成这篇文章之前还没有完全归功于它们,如果可以的话,我只想在下面发布相关部分?
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;Part of DCL File:
": row { "
" : list_box { label = \"Select Tag(s)\"; key = \"tags\"; multiple_select = true; }" ;;List box populated elsewhere
" }"
": row { "
" : button { key = \"ButSEL\"; label = \"Select All Tags\"; }" ;;Select All Button
" }"
;;.......
(action_tile "tags" "(setq tagreturn $value)")
(action_tile "ButSEL" "(c:SEL_ALL)") ;;When button ButSEL pressed run routine SEL_ALL below.
;;.......
(setq tagreturn;;create tag list into tagreturn (I think)
(if (= 1 (start_dialog))
(mapcar '(lambda ( x ) (nth x l)) (read (strcat "(" tagreturn ")")))
)
)
tagreturn
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;This Select all routine doesn't quite work. it highlights the list items but doesn't select them
(defun c:SEL_ALL ()
;;(set_tile "tags" "0 1 2 3 4 5 6") ;;simple only highlights the items, not selects them
(setq acount 0) ;;Use a loop
(repeat 50 ;;How to count the length of the list and use here?
(set_tile "tags" (itoa acount));;Again only highlights the items and not selects them
(setq account (acount + 1))
)
)
(我曾尝试将上述内容包装在代码标签中,但它不想对我起作用,有什么想法吗?为什么不?) 你好
在你看来,突出显示和选择项目之间有什么区别? 嗨,塔瓦,
谢谢你看了这么远。
是的,我不太清楚。
“高亮显示”-当我按下“全选”按钮时,列表框中的项目都高亮显示,就好像它们已经被选中一样,但当我按下DCL框上的“OK”时,没有任何信息传递到例程的下一部分-就好像这些项目只高亮显示但没有被选中一样
“选定”-假设我使用键盘或鼠标选择并高亮显示列表框中的项目,然后按“确定”将选定的项目传递到例程的下一部分。使用鼠标/键盘抓取项目供以后使用
希望这有意义? 你好
您向列表提供的项目列表必须分配给一个变量,因此假设变量的名称为“lst”
仅供参考当您在激活多选项的列表上使用get\u tile,并且用户高亮显示/选择了多个项目时,它将返回例如:“0 1”
因此,我们需要将这个字符串包装在一个列表中,以便能够从变量“lst”中检索相同的相关项目编号,该变量将项目添加到列表中。
下面只是一个示例,让您了解如何从列表属性中检索值。
(action_tile "oki" "(if (setq rtn (get_tile \"tags\")) (mapcar '(lambda (x) (setq l (cons (nth x lst) l))) (read (strcat \"(\" rtn \")\")))) (done_dialog)")
最后,变量“l”应该包含列表“tags”中的选定项,您需要使用反向函数按变量“lst”中的顺序获取这些项
希望这不是太多。所以只要问问你是否坚持了什么。 更多细节和示例:
Dcl:
"test : dialog { label = \"Tag list\"; fixed_width = true;
: list_box { key = \"tags\"; height = 16; multiple_select = true;}
: button { label = \"select all\"; key = \"ButSEL\";}
: button { label = \"Okay\"; key = \"oki\"; is_default = true;}
: button { label = \"Exit\"; key = \"esc\"; is_cancel = true;}}"
节目的最后一部分:
(defun highlight (len / i)
(setq i -1)
(repeat len
(set_tile "tags" (itoa (setq i (1+ i))))
)
)
(setq lst '("A" "B" "C" "D"))
(start_list "tags") (mapcar 'add_list lst) (end_list)
(action_tile "ButSEL" "(highlight (length lst))")
(action_tile "oki" "(if (setq rtn (get_tile \"tags\")) (mapcar '(lambda (x) (setq l (cons (nth x lst) l))) (read (strcat \"(\" rtn \")\")))) (done_dialog)")
(action_tile "esc" "(done_dialog)")
因此,变量“l”应该具有带有键“tags”的列表的返回值,您需要使用以下代码按照“lst”变量中的定义对列表重新排序:
(reverse l)
请阅读代码发布指南,并编辑代码以包含在代码标签中。
Your Code Here=
Your Code Here 感谢SLW210-添加了代码标签。
Tharwat,我能看到它应该如何工作。。。现在还不是时候,我今天会解决它,试着找出我做错了什么
让我知道你进展如何。
祝你好运 你好
只是一个快速更新-我无法在周五完成这项工作,距离现在还很近(我有一些怀疑我需要看什么),但现在我面前有一堆图纸。我现在将把它放在一边,稍后再处理 嗨,塔瓦特,我正在赶上一切。我做得很好,虽然有点混乱,但我想我在这过程中学到了一些东西,谢谢
最后,我无法让您的方法正常工作(我想我知道为什么,可能是我在某个地方混淆了变量名)
为了使其工作,我将最后一个函数SEL_ALL更改为:
(defun c:SEL_ALL (len) ;;len = length of tags list
(setq tagreturn "") ;;tagreturn = positions in drop list of selected items
(setq acount 0) ;;acount = a counter
(repeat len
(set_tile "tags" (itoa acount))
(setq tagreturn (strcat (strcat tagreturn (itoa acount)) " "))
(setq acount (1+ acount))
)
)
再次感谢
页:
[1]
2