BTW, the OK & Cancel buttons are a predefined widget and can be created using just:
ok_cancel;
Would the OK & Cancel buttons going to be without a action_tile and get_tile functions and so on ..... ?
That would depend upon whether you needed any expressions evaluated before the dialog is closed, (i.e. before a call to
done_dialog).
If no expressions need to be evaluated when the user clicks OK or Cancel, these buttons do not require
action_tile statements since the
done_dialog call is predefined with tiles that use the 'accept' or 'cancel' keys, with a status argument of 1 and 0 respectively.
A quick example:
DCL code (save as
example.dcl)
example : dialog { label = "Select a Block"; spacer;
: popup_list { key = "blocks"; }
spacer; ok_cancel;
}
LISP code:(defun c:test ( / block def id lst )
(if
(and
(progn
(while (setq def (tblnext "BLOCK" (null def)))
(if (zerop (logand 4 (cdr (assoc 70 def))))
(setq lst (cons (cdr (assoc 2 def)) lst))
)
)
(if lst (setq lst (acad_strlsort lst)))
)
(< 0 (setq id (load_dialog "example.dcl")))
(new_dialog "example" id)
)
(progn
(start_list "blocks")
(foreach block lst (add_list block))
(end_list)
(set_tile "blocks" (setq block "0"))
(action_tile "blocks" "(setq block $value)")
(if (= 1 (start_dialog))
(alert (strcat "You selected:\n" (nth (atoi block) lst)))
)
)
)
(if (< 0 id) (unload_dialog id))
(princ)
)