明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 555|回复: 0

[基础] 对话框输入限制及另行隐藏功能示例---新手请进

[复制链接]
发表于 2020-11-12 14:02 | 显示全部楼层 |阅读模式
一般地,对话框主要用于传递参数较多
输出的参数表用于其他功能函数使用

该例对输入框edit_box对非数字输入限制,要求重新输入
同时在key1(高度输入框)输入mm,则会另行提示"新功能密码ABC!"比如只有某些使用者知道的提示

(defun c:cs nil(set_date(list "2.5" "2" "2" "0")))
;records对话框初值列表
(defun set_date (records / get_date dcl_str mm1 mm2 str file f dcl_id dd)       
        (defun get_date ()(mapcar 'get_tile(list "key1" "key2" "key3" "key4")))       
        (setq dcl_str '(
"set_datedcl:dialog {"
"    :boxed_column {label = \"参数设置\" ;"
"        :edit_box {edit_width = 10 ;key = \"key1\" ;label = \"高度\" ;}"
"        :edit_box {edit_width = 10 ;key = \"key2\" ;label = \"宽度\" ;}"
"        :popup_list {edit_width = 9.2 ;key = \"key3\" ;label = \"精度\" ;}"
"        :toggle {key = \"key4\" ;label = \"勾选功能\" ;}"
"    }"
"    :spacer {}"
"    ok_cancel;" ; 采用ok_cancel,非法输入就会返回要求重新输入
"    :text {label = \"by wzg356\" ;}}"
                    )
    )
    (setq mm1 "新功能密码ABC!"  mm2 "输入框非数字!")
    (setq file (vl-filename-mktemp "DclTemp.dcl"))
    (setq f (open file "w"))
    (foreach str dcl_str(princ "\n" f)(princ str f))
    (close f)       
        (setq dcl_id (load_dialog file))
        (new_dialog "set_datedcl" dcl_id)       
        (start_list "key3" 3)
        (mapcar 'add_list (list "0" "0.0" "0.00" "0.000"))
        (end_list)
        (mapcar '(lambda (x y) (set_tile x y))(list "key1" "key2" "key3" "key4")records)
        (action_tile "accept" "(if (vl-every 'numberp(mapcar 'read (setq records(get_date))))(done_dialog 1)(if(= (car records) \"mm\")(alert mm1)(alert mm2)))")               
        (setq dd (start_dialog))
        (unload_dialog dcl_id)
        (vl-file-delete file);删除临时dcl文件
        (if (= dd 1)records);正常输出合法参数或nil                       
)

评分

参与人数 1明经币 +1 收起 理由
USER2128 + 1 赞一个!

查看全部评分

"觉得好,就打赏"
还没有人打赏,支持一下
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-3-29 01:57 , Processed in 0.255477 second(s), 29 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表