Welcome to the Southern African Autolisp Website.
You are Visitor Number
|
| Home. | Page II. |
To nest dialogue boxes is pretty straightforward. You simply call the new,
nested dialogue box from within an action expression or callback function.
For example :
(action_tile "next" "(nextfunction)")
This simply says that when the tile with the key of 'next' is selected, then
run the function (nextfunction). (nextfunction), of course, would have it's
own dialogue statements.
Just a couple of comments on nesting dialogue boxes.
Firstly, you cannot use the previous dialogue box whilst a nested dialogue is
active. You must close the nested dialogue first.
And secondly, AutoCAD states that there is a limit of no more than eight nested
dialogue boxes allowed, but recommends a maximum of four.
(Try it, I haven't!!!)
Thirdly, try and keep each nested dialogue smaller than the preceeding dialogue.
Here's an example of a function with a main dialogue box and two nested
dialogue boxes.
First the DCL Coding:
main : dialog {
label = "Main Dialogue";
: column {
: text {
key = "txt1";
value = "This is the main dialogue box.";
}
: text {
key = "txt2";
value = "To display the next, nested dialogue,";
}
: text {
key = "txt3";
value = "Press Next....";
}
}
: row {
: spacer { width = 1; }
: button {
label = "OK";
key = "accept";
width = 12;
fixed_width = true;
mnemonic = "O";
is_default = true;
}
: button {
label = "Next";
key = "next";
width = 12;
fixed_width = true;
mnemonic = "N";
}
: button {
label = "Cancel";
key = "cancel";
width = 12;
fixed_width = true;
mnemonic = "C";
is_cancel = true;
}
: spacer { width = 1;}
}
}
////////////////////////////////////////////////
nest1 : dialog {
label = "1st Nested Dialogue";
: column {
: text {
key = "txt1";
value = "This is the first nested dialogue box.";
}
: text {
key = "txt2";
value = "To display the next, nested dialogue, press Next";
}
}
: row {
: spacer { width = 1; }
: button {
label = "OK";
key = "accept";
width = 12;
fixed_width = true;
mnemonic = "O";
is_default = true;
}
: button {
label = "Next";
key = "next";
width = 12;
fixed_width = true;
mnemonic = "N";
}
: button {
label = "Cancel";
key = "cancel";
width = 12;
fixed_width = true;
mnemonic = "C";
is_cancel = true;
}
: spacer { width = 1;}
}
}
////////////////////////////////////////////////
nest2 : dialog {
label = "2nd Nested Dialogue";
: column {
: text {
key = "txt1";
value = "This is the last nested dialogue box.";
}
}
: row {
: spacer { width = 1; }
: button {
label = "OK";
key = "accept";
width = 12;
fixed_width = true;
mnemonic = "O";
is_default = true;
}
: button {
label = "Cancel";
key = "cancel";
width = 12;
fixed_width = true;
mnemonic = "C";
is_cancel = true;
}
: spacer { width = 1;}
}
}
////////////////////////////////////////////////
(defun c:nest ()
;define the function
(setq dcl_id (load_dialog "nest.dcl"))
;load the DCL file
(if (not (new_dialog "main" dcl_id))
;load the dialogue box
(exit)
;if not loaded exit
)
(action_tile
"cancel"
"(done_dialog)
(setq result nil)"
)
;do this if Cancel button selected
(action_tile
"accept"
"(done_dialog)
(setq result T)"
)
;do this if OK button selected
(action_tile
"next"
"(nest1)"
)
;if Next button is selected, call
;the nested dialogue function
(start_dialog)
;start the dialogue
(unload_dialog dcl_id)
;unload the dialogue
(princ)
);defun
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun nest1 ()
;define the function
(setq dcl_id1 (load_dialog "nest.dcl"))
;load the DCL file
(if (not (new_dialog "nest1" dcl_id1))
;load the nested dialogue box
(exit)
;if not loaded exit
)
(action_tile
"cancel"
"(done_dialog)
(setq result1 nil)"
)
;if cancel selected do this
(action_tile
"accept"
"(done_dialog)
(setq result1 T)"
)
;if OK selected do this
(action_tile
"next"
"(nest2)"
)
;if Next selected call the
;second nested dialogue function
(start_dialog)
;start the nested dialogue box
(unload_dialog dcl_id1)
;unload the nested dialogue box
(princ)
);defun
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun nest2 ()
;define the function
(setq dcl_id2 (load_dialog "nest.dcl"))
;load the DCL file
(if (not (new_dialog "nest2" dcl_id2))
;load the second nested dialogue box
(exit)
;if not found exit
)
(action_tile
"cancel"
"(done_dialog)
(setq result2 nil)"
)
;do this if Cancel selected
(action_tile
"accept"
"(done_dialog)
(setq result2 T)"
)
;do this if OK selected
(start_dialog)
;start the second nested dialogue box
(unload_dialog dcl_id2)
;unload it
(princ)
);defun
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(princ);load clean
| Home. | Page II. |