popup_list and list_box

popup_list and list_box

cadking2k5
Advocate Advocate
1,989 Views
5 Replies
Message 1 of 6

popup_list and list_box

cadking2k5
Advocate
Advocate
I want each color FRUIT CARS in a different list_box and just the size of the text // DCL definition myTest : dialog { label = "Test list controls"; : list_box { key = "listbox"; width = 20; } : popup_list { key = "popup"; width = 20; } ok_only; } ;; LISP code (defun populate_list (tile item lst) (start_list tile) (mapcar 'add_list (cadr (nth item lst))) (end_list) ) (defun listtest () ;; set up data (setq myList '(("FRUIT" ("APPLES" "ORANGES" "PEARS")) ("COLORS" ("RED" "GREEN" "BLUE")) ("CARS" ("VW" "CHEVY" "FORD")) ) ) (setq dcl_id (load_dialog "testdlg.dcl")) (cond ((new_dialog "myTest" dcl_id) ;; fill "popup" with CAR item of myList (start_list "popup") (mapcar 'add_list (mapcar 'car myList)) (end_list) ;; fill "listbox" initially, according to default value of "popup" ;; (value of "0" unless otherwise specified in the dcl definition) (populate_list "listbox" 0 myList) ;; define callback to populate "listbox" according to ;; users choice in the "popup" tile (action_tile "popup" "(populate_list \"listbox\" (atoi $value) myList)") (start_dialog) ) ) )
0 Likes
1,990 Views
5 Replies
Replies (5)
Message 2 of 6

john.uhden
Mentor
Mentor

I think that getting rid of (cond will makes things work for you.

 

BTW, in the future, please post your code using that </> icon for "Insert Code."

I am one who cannot follow code unless it is indented properly.

John F. Uhden

0 Likes
Message 3 of 6

cadking2k5
Advocate
Advocate
so if I get rid of the Cond I will give it three different list_box that have the one color one fruit and one car in each one of them when I pick it from the popup_box and makes the list box the size of the text men that is one power command
0 Likes
Message 4 of 6

scot-65
Advisor
Advisor
I am having trouble with what you are trying to accomplish?

Do you want the height of the list box adjusted based on the number of items in the list?
Short answer is no. DCL is static once start_dialog is called.

In your DCL definition, you are not assigning a height to the list box. If you were
to write the DCL on the fly, one would add 2 (or 3) to the number of items in the list,
as the height attribute, but it will not display exactly, all the time.
There is no "edit_height" in DCL. Rather, the height will "snap" to the next available line.

Regarding your lists, there are not enough list declarations (meaning a list within
a list that is within a "master" list). You only show one list ("master").
<code>
(setq myList '(
'("FRUIT" '("APPLES" "ORANGES" "PEARS"))
'("COLORS" '("RED" "GREEN" "BLUE"))
'("CARS" '("VW" "CHEVY" "FORD"))
))
</code>
*untested*
With that, defun populate_list will be somewhat simplified and easier to understand.

Switch positions of list box and popup in the DCL. It was also confusing me.
"Select an item in the popup and the list box will populate...".

???

Scot-65
A gift of extraordinary Common Sense does not require an Acronym Suffix to be added to my given name.

0 Likes
Message 5 of 6

cadking2k5
Advocate
Advocate

maybe this will help you understand more this is what I go so far but nothing is coming up in the first list box and with your nothing comes up in any of the list boxes


(defun populate_list (tile item lst)
(start_list tile)
(mapcar 'add_list (cadr (nth item lst)))
(end_list)
)

(defun populate_list1 (tile1 item1 lst1)
(start_list tile1)
(mapcar 'add_list (cadr (nth item1 lst1)))
(end_list)
)

(defun savevars ()
(setq sm (atoi (get_tile "metric")))
(setq mm (get_tile "metric"))
)
(defun c:mytest ()
;; set up data
(setq myList1 '(("M5" ("3.875" ))
("M6" ("4.375" ))
("M8" ("5.675" ))
)
)
(setq myList2 '(("M5" ("8" ))
("M6" ("10" ))
("M8" ("13" ))
)
)
(setq dcl_id (load_dialog "mytest.dcl"))
(cond ((new_dialog "mytest" dcl_id)

;; fill "popup" with CAR item of myList
(start_list "popup")
(mapcar 'add_list (mapcar 'car myList1))
(end_list)

;; fill "listbox" initially, according to default value of "popup"
;; (value of "0" unless otherwise specified in the dcl definition)
; (populate_list "listbox" 0 myList1)

; (populate_list1 "listbox1" 0 myList2)

;; define callback to populate "listbox" according to
;; users choice in the "popup" tile
(action_tile "popup" "(populate_list \"listbox\" (atoi $value) myList1)")

(action_tile "popup" "(populate_list1 \"listbox1\" (atoi $value) myList2)")

(start_dialog)
)
)
)


mytest : dialog {
label = "Test list controls";
//:column {
:row {
: popup_list {
key = "popup";
edit_width = 10;
}
//}
//:column {
:row {
: list_box {
key = "listbox";
label = dia ;
height = 2.25 ;
width = 10;
}
: list_box {
key = "listbox1" ;
label = pitch ;
height = 2.25 ;
width = 10;
}
:radio_button {
key = "metric" ;
label = "MM";
mnemonic = "M" ;
}
}
}
ok_cancel;
}

0 Likes
Message 6 of 6

scot-65
Advisor
Advisor
Looking at your code, and trying a few iterations,
I will have to take back the list within a list I mentioned earlier.
(It's been a while since I did this type of exercise and was
going on from [failing] memory) Apology accepted?

Only one action_tile can be associated with one tile.
The last one wins.

???

Scot-65
A gift of extraordinary Common Sense does not require an Acronym Suffix to be added to my given name.

0 Likes