Here's a small example to show what I mean. When selecting items in the list_box, it builds a list of selected items. It also checks if the edit_box holds a value. If so, enable the buttons. If not, disable the buttons. This is where the GET_TILE comes in.
When leaving the edit_box, it checks to see if any list of selected items has been built. If so, and if a value has been entered, enable the buttons. If not, disable them.
It would be easier to do this on getting focus but ignoring events in general is, as hinted before, one of the many shortcomings of DCL. So this could be sort of a way to compensate. The user won't see it much different.
;;LSP code
;;; Function from the online help "Working with Programmable
;;; Dialog Boxes" -> "Processing List Elements" to convert
;;; a multiple list_box selection to a list (edited to rid of
;;; the global list)
(defun MK_LIST (readlist displist / count item retlist)
(setq count 1)
(while (setq item (read readlist))
(setq retlist (cons (nth item displist) retlist))
(while (and (/= " " (substr readlist count 1))
(/= "" (substr readlist count 1))
)
(setq count (1+ count))
)
(setq readlist (substr readlist count))
)
(reverse retlist)
)
(defun whdjr (/ dcl_id samples enableBtns doListBox doEditBox listpicks)
;; To toggle is_enabled for two named buttons
(defun enableBtns (flag)
(mode_tile "btn_update" flag)
(mode_tile "btn_apply" flag)
)
;; Callback for "list_1" list_box. Checks if buttons
;; should be en-/disabled and returns selected
;; items in a list
(defun doListBox (value lst)
(if (and (/= (get_tile "edit_1") "")
(setq lst (MK_LIST value lst))
)
(enableBtns 0)
(enableBtns 1)
)
lst
)
;; Callback for edit_box "edit_1". Checks to see if
;; buttons should be en-/disabled.
;; Should also contain validation and storage of contents.
(defun doEditBox (value lst)
;; validation could go here ...
(if (and lst (/= value ""))(enableBtns 0)(enableBtns 1))
;; return value could go here ...
)
(setq samples '("Item_1" "Item_2" "Item_3" "Item_4"))
(setq dcl_id (load_dialog "test.dcl"))
(cond ((new_dialog "whdjr" dcl_id)
;; fill list into "list_1"
(start_list "list_1")
(mapcar 'add_list samples)
(end_list)
;; initial disabling of buttons
(mode_tile "btn_update" 1)
(mode_tile "btn_apply" 1)
(action_tile "list_1"
"(setq listpicks (doListBox $value samples))"
)
(action_tile "edit_1" "(doEditBox $value listpicks)")
(start_dialog)
)
)
)
//DCL code
whdjr : dialog {
: list_box {
key = "list_1";
width = 16;
multiple_select = true;
}
: edit_box {
key = "edit_1";
edit_width = 16;
}
: button {
key = "btn_update";
label = "Update";
}
: button {
key = "btn_apply";
label = "Apply";
}
cancel_button;
}