The Buzzard 发表于 2022-7-6 04:40:04

列表框,如何突出显示

大家好,
 
我决定在我的一个dcl中从popup_列表切换到list_框。我设置了默认值,它们工作正常。我在这里遇到的问题是,当dcl首次出现时,值没有突出显示。我尝试使用value=0;,但这没什么作用,所以我把它去掉了。
 
缺少什么?如果能在这方面得到任何帮助,我将不胜感激。
谢谢
 
             : column {
            : boxed_column {
                label = "Class";
                : list_box {
                  key = "CLASS";
                  height = 8.0;
                  width = 9.0;
                  fixed_height = true;
                  fixed_width = true;
                  alignment = centered;
                }
            }
            }
            : column {
            : boxed_column {
                label = "Size";
                : list_box {
                  key = "PSIZ";
                  height = 8.0;
                  width = 9.0;
                  fixed_height = true;
                  fixed_width = true;
                  alignment = centered;
                }
            }
            }

JohnM 发表于 2022-7-6 04:46:05

我认为(mode\u tile key mode)可以做到这一点

The Buzzard 发表于 2022-7-6 04:48:40

谢谢你,约翰,
 
但是mode_互动程序会将注意力集中在互动程序上,而不会突出显示它。

JohnM 发表于 2022-7-6 04:51:58

你想突出某个特定项目,对吗?
我认为你使用set_tile,然后将mode tile设置为mode 3

The Buzzard 发表于 2022-7-6 04:55:58

这适用于编辑框内容,而不是列表框。

JohnM 发表于 2022-7-6 04:58:52

现在,保存dcl和lisp文件,然后在AutoCAD中映射到文件夹的路径,在vlide编辑器中加载文件并运行lisp文件,您将看到列表框中的项目高亮显示。在lisp文件中,您将看到将set\u tile设置为列表中的项目,并将mode tile设置为高亮显示它们。您可以创建变量来记住这些。
 

(defun test:DialogInput
      (/ dcl_id result userclick dialogLoaded dialogShow)
(setq dialogLoaded T
dialogShow   T      
) ;_ end of setq
(if (= -1 (setq dcl_id (load_dialog "test.DCL")))
   (progn
   (princ "\nERROR: Cannot load test.dcl")
   (setq dialogLoaded nil)
   ) ;_ end of progn
) ;_ end of if
(if (and (not (new_dialog "test_dlg" dcl_id))
   dialogLoaded
   ) ;_ end of and
   (progn   
   (princ "\nERROR: Cannot show dialog test.dlg")
   (setq dialogShow nil)
   ) ;_ end of progn
) ;_ end of if
(if (and dialogLoaded dialogShow)
   (progn
   (setq lst1 '("150" "300" "400" "600" "900" "1500" "2500"))
   (setq lst2 '("1/2" "3/4" "1" "1-1/4" "1-1/2" "1-3/4" "2"))
(start_list "CLASS" 3)
   (mapcar 'add_list lst1);_
   (end_list)
   (set_tile "CLASS" "2")
(mode_tile "CLASS" 3);_

      (start_list "PSIZ" 3);_
   (mapcar 'add_list lst2)
   (end_list)
    (set_tile "PSIZ" "2")
(mode_tile "PSIZ" 3);_

   (action_tile "cancel" "(done_dialog)(setq UserClick nil) ")
   (start_dialog)   
   (unload_dialog dcl_id)
      ;_ end of if
   ) ;_ end of progn
) ;_ end of if
)


test_dlg : dialog {
: row {
: column {
            : boxed_column {
                label = "Class";
                : list_box {
                  key = "CLASS";
                  height = 8.0;
                  width = 9.0;
                  fixed_height = true;
                  fixed_width = true;
                  alignment = centered;
                }
            }
            }
            : column {
            : boxed_column {
                label = "Size";
                : list_box {
                  key = "PSIZ";
                  height = 8.0;
                  width = 9.0;
                  fixed_height = true;
                  fixed_width = true;
                  alignment = centered;
                }
            }
            }
            }

: row {          // defines the OK/Cancel button row
: spacer { width = 1; }
: button {    // defines the OK button
   label = "OK";
   is_default = true;
   key = "accept";
   width = 8;
   fixed_width = true;
}
: button {    // defines the Cancel button
   label = "Cancel";
   is_cancel = true;
   key = "cancel";
   width = 8;
   fixed_width = true;}
   }


}//_end

Lee Mac 发表于 2022-7-6 04:59:31


(set_tile <key> "1")

The Buzzard 发表于 2022-7-6 05:03:34

谢谢李,
 
但它没有做任何事情。我使用单选按钮设置类列表的值,类列表依次设置大小列表的值。最初的问题是,当对话框第一次启动时,没有按照默认设置突出显示每个列表中的第一个值。
 
选择后,这些值将高亮显示,并在对话框重新出现时记住其上次选择。
 
我不经常使用列表框,但在这种情况下,这似乎是一个很好的改变。男孩,我错了。

Lee Mac 发表于 2022-7-6 05:05:36

Buzzard,这并不太难,列表框的工作方式与popup_列表相同(哦,它应该是“0”)
 
例如:
 

(defun c:test ( / dc f lst item )
(cond
   (
   (or
       (<= (setq dc (load_dialog "ListBox.dcl")) 0)
       (not (new_dialog "test" dc))
   )
   )
   (t
   (start_list "lst")
   (mapcar (function add_list) (setq lst '("Item1" "Item2" "Item3")))
   (end_list)

   (setq item (set_tile "lst" "0"))

   (action_tile "lst" "(setq item $value)")

   (setq f (start_dialog) dc (unload_dialog dc))

   (if (= f 1)
       (alert
         (strcat "You Selected: "
         (nth (atoi item) lst)
         )
       )
   )
   )
)
(princ)
)

 
大小现在突出显示,但不是类。

The Buzzard 发表于 2022-7-6 05:09:09

我只设置变量,以便在用户点击OK之前没有选择任何项目时,变量具有tile_值。
 
set\u tile语句是突出显示列表框项的函数-不会有太多错误。
页: [1] 2
查看完整版本: 列表框,如何突出显示