Another problem with a dos_proplist alternative:
This function also works with association lists
f.e. (setq x '(("Title" . "Floorplan") ("Project" . "Project A")))
I would like that whenever the user selects another item from the list that the focus is on the edit box and that the content is selected.
Normally achieved with mode_tile 3.
This does not seem to work ? What am I missing ?
Notice the allow_accept;
;; Displays a DCL list box allowing the user to enter a string
(defun @main_dcl-PropList (tit$ msg$ lst / dch des tmp rtn lsel )
(cond
((not
(and
(setq tmp (vl-filename-mktemp nil nil ".dcl"))
(setq des (open tmp "w"))
(write-line
(strcat
"PropList:dialog{initial_focus=\"edit\";label=\"" tit$
"\";spacer;" ":text{key=\"TXT\";label=\"" msg$ "\";}"
":list_box{key=\"list\";width=40;tabs=\"20\";}"
":edit_box{key=\"edit\";width=40;allow_accept=true;}spacer;ok_cancel;}"
)
des
)
(not (close des))
(< 0 (setq dch (load_dialog tmp)))
(new_dialog "PropList" dch)
)
)
(prompt "\nError @main_dcl loading PropList dialog.")
)
(t
(@main_dcl-UpdateList lst)
(setq lsel "0")
(set_tile "list" lsel)
(set_tile "edit" (cdr (nth (fix (atof lsel)) lst)))
(action_tile
"list"
"(set_tile \"edit\" (cdr (nth (fix (atof (setq lsel $value))) lst)))) (mode_tile \"edit\" 3)"
)
(action_tile
"edit"
"(setq lst (@main_dcl-ListReplace lst (fix (atof lsel)) (cons (car (nth (fix (atof lsel)) lst)) $value)))(@main_dcl-UpdateList lst)"
)
(setq rtn
(if (= (start_dialog) 1)
lst
nil
)
)
)
)
(if (< 0 dch)
(unload_dialog dch)
)
(if (and tmp (setq tmp (findfile tmp)))
(vl-file-delete tmp)
)
rtn
)
(defun @main_dcl-ListReplace ( alist position newitem / i )
(setq i -1)
(mapcar '(lambda (x) (if (= position (setq i (1+ i))) newitem x)) alist)
)
(defun @main_dcl-UpdateList (lst / l)
(start_list "list")
(foreach l lst
(add_list (strcat (car l) "\t" (cdr l)))
)
(end_list)
)