- UID
- 525
- 积分
- 3148
- 精华
- 贡献
-
- 威望
-
- 活跃度
-
- D豆
-
- 在线时间
- 小时
- 注册时间
- 2002-1-14
- 最后登录
- 1970-1-1
|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
关于设计对话框自定义退出按纽的讨论:
大家知道, 由于AUTOCAD使用的都是模态对话框, 对话框至少要包括一个OK按钮(或与其等效的控件) 在结束对话框时使用. 大部分对话框还含有一个CANCEL按钮, 既不做任何另外的动作就退出对话框.
也就是说, 在正常情况下, 只有在按下了OK/CANCEL按钮之后, 对话框才能结束.
但在实际使用中, 用户往往希望选择了一个功能按钮, 如图象按钮或其他执行特定动作的按钮(如用户定义的某个动作或函数)之后, 便结束(退出)对话框, 这时候OK 按钮就显得多余了.
帮助文件和一些文献介绍, 自定义退出按纽可使用retirement_button控件原型. 例如, 如果要建立一个用于删除数据的对话框, 则将OK按钮改成"Destroy" 更方便安全一些.
相应的程序码:
destroy_button : retirement_button {
label = "&destroy";
key="destory";
}
定义了自定义的推出按钮后, 将其嵌入标准控件中:
destroy_cancel_help : column {
: row {
fixed_width = true;
alignment = centered;
destroy_button;
: spacer { width = 2; }
cancel_button;
: spacer { width = 2; }
help_button;
}
}
创建一个新的祖件, 用新按钮替换OK_BUTTON:
destroy_cancel_help : column {
: row {
fixed_width = true;
alignment = centered;
destroy_button;
: spacer { width = 2; }
: cancel_button { is_default = true; }
: spacer { width = 2; }
help_button;
}
}
看起来, 非常繁琐.
实际上, 任何一个可操作的控件能可以使对话框结束(退出)
只要有(done_dialog) (term_dialog)函数
(done_dialog)- 函数终止一个对话框(详见帮助文件)
把(done_dialog)的结束码改成与OK按钮相同的值,就会在选中调用这个函数的按钮后,结束对话框.
以下是一个没有OK按钮(退出按钮为select)的实例:
dbend : dialog {label = "Preassemly-Tube Bending";key="db"; color=3;
: row {
: image { key="i"; width=32; aspect_ratio = 0.6; color=0;}
: column {
: edit_box {label="Angle"; key = "ang"; value="45"; edit_width = 3;}
: edit_box {label="Radius"; color=3;key = "rad"; value="0.51"; edit_width = 3;}
spacer_1;spacer_1;
: edit_box {label ="Ref Value"; key = "lv"; value="0.20";edit_width = 4;}
spacer_1;
}
}
spacer;
: row { spacer;
: button {label="Select Bend Profile"; key="select";}
spacer;
cancel_button;
spacer;
}
spacer;
: row {
: image { key = "im" ; width = 4; fixed_width= true;}
: paragraph {
: text_part { label = "Designed and Created";alignment=right;}
: text_part { label = "by Richard Liang";alignment=right;}
}
}
}
当然还可以定义图象按钮作为对话框退出按钮, 你只要双击图象按钮, 对话框既退出. 在此不赘述. 还有没有其他更好的方法? 请教. |
|