Jump to content

List Box, How Do You Highlight The Value?


The Buzzard

Recommended Posts

Hello to all,

 

I decided to switch from popup_lists to list_boxes in one of my dcl's. I have the default values set and they work fine. The problem I am having here is the values do not highlight when the dcl first appears. I tried using value = 0;, But this did nothing so I removed it.

 

Is something missing? I would appreciate any help on this.

Thanks

 

             : column {
              : boxed_column {
                label = "Class";
                : list_box {
                  key = "CLASS";
                  height = 8.0;
                  width = 9.0;
                  fixed_height = true;
                  fixed_width = true;
                  alignment = centered;
                }
              }
            }
            : column {
              : boxed_column {
                label = "Size";
                : list_box {
                  key = "PSIZ";
                  height = 8.0;
                  width = 9.0;
                  fixed_height = true;
                  fixed_width = true;
                  alignment = centered;
                }
              }
            }

Document1.JPG

Link to comment
Share on other sites

  • Replies 50
  • Created
  • Last Reply

Top Posters In This Topic

  • The Buzzard

    26

  • Lee Mac

    17

  • JohnM

    4

  • Bhull1985

    2

Top Posters In This Topic

Posted Images

Thanks John,

 

But mode_tile will focus attention to the tile, It will not highlight it.

Link to comment
Share on other sites

you want to highlite a particular item correct?

i think you use set_tile then mode tile to mode 3

That would work for edit box contents, Not list box.

Link to comment
Share on other sites

Here ya go, save the dcl and lisp file then in AutoCAD map a path to the folder load the files in the vlide editor and run the lisp file and you will see the items in the list boxes highlighted. In the lisp file you will see set_tile set to the item in the list and mode tile set to highlight them . You can create variables for these to be remembered .

 

[font=Times New Roman][font=Times New Roman](defun test:DialogInput[/font]
[font=Times New Roman]      (/ dcl_id result userclick dialogLoaded dialogShow)[/font]
[font=Times New Roman] (setq dialogLoaded T[/font]
[font=Times New Roman]dialogShow   T       [/font]
[font=Times New Roman] ) ;_ end of setq[/font]
[font=Times New Roman] (if (= -1 (setq dcl_id (load_dialog "test.DCL")))[/font]
[font=Times New Roman]   (progn  [/font]
[font=Times New Roman]     (princ "\nERROR: Cannot load test.dcl")[/font]
[font=Times New Roman]     (setq dialogLoaded nil)[/font]
[font=Times New Roman]   ) ;_ end of progn[/font]
[font=Times New Roman] ) ;_ end of if[/font]
[font=Times New Roman] (if (and (not (new_dialog "test_dlg" dcl_id))[/font]
[font=Times New Roman]   dialogLoaded[/font]
[font=Times New Roman]     ) ;_ end of and[/font]
[font=Times New Roman]   (progn     [/font]
[font=Times New Roman]     (princ "\nERROR: Cannot show dialog test.dlg")[/font]
[font=Times New Roman]     (setq dialogShow nil)[/font]
[font=Times New Roman]   ) ;_ end of progn[/font]
[font=Times New Roman] ) ;_ end of if[/font]
[font=Times New Roman] (if (and dialogLoaded dialogShow)[/font]
[font=Times New Roman]   (progn[/font]
[font=Times New Roman]   (setq lst1 '("150" "300" "400" "600" "900" "1500" "2500"))[/font]
[font=Times New Roman]   (setq lst2 '("1/2" "3/4" "1" "1-1/4" "1-1/2" "1-3/4" "2"))[/font]
[font=Times New Roman]  (start_list "CLASS" 3) [/font]
[font=Times New Roman]     (mapcar 'add_list lst1);_[/font]
[font=Times New Roman]     (end_list)[/font]
[font=Times New Roman]   (set_tile "CLASS" "2")[/font]
[font=Times New Roman](mode_tile "CLASS" 3);_[/font]

[font=Times New Roman]      (start_list "PSIZ" 3);_[/font]
[font=Times New Roman]     (mapcar 'add_list lst2)  [/font]
[font=Times New Roman]     (end_list)[/font]
[font=Times New Roman]    (set_tile "PSIZ" "2")[/font]
[font=Times New Roman](mode_tile "PSIZ" 3);_[/font]

[font=Times New Roman]     (action_tile "cancel" "(done_dialog)(setq UserClick nil) ")[/font]
[font=Times New Roman]     (start_dialog)   [/font]
[font=Times New Roman]     (unload_dialog dcl_id)[/font]
[font=Times New Roman]      ;_ end of if[/font]
[font=Times New Roman]   ) ;_ end of progn[/font]
[font=Times New Roman] ) ;_ end of if [/font]
[font=Times New Roman])[/font]
[/font]

 

 
test_dlg : dialog {
: row {
: column {
              : boxed_column {
                label = "Class";
                : list_box {
                  key = "CLASS";
                  height = 8.0;
                  width = 9.0;
                  fixed_height = true;
                  fixed_width = true;
                  alignment = centered;
                }
              }
            }
            : column {
              : boxed_column {
                label = "Size";
                : list_box {
                  key = "PSIZ";
                  height = 8.0;
                  width = 9.0;
                  fixed_height = true;
                  fixed_width = true;
                  alignment = centered;
                }
              }
            }
            }

: row {          // defines the OK/Cancel button row
 : spacer { width = 1; }
 : button {    // defines the OK button
   label = "OK";
   is_default = true;
   key = "accept";
   width = 8;
   fixed_width = true;
 }
 : button {    // defines the Cancel button
   label = "Cancel";
   is_cancel = true;
   key = "cancel";
   width = 8;
   fixed_width = true;}
   }


}//_end
Link to comment
Share on other sites

(set_tile <key> "1")

Thanks Lee,

 

But it does not do a thing. I am using radio buttons to set the values of the Class list and the Class list in turn sets the value for Size list. The initial problem is when the dialog firsts starts there is no highlighting of the first value in each list as per the default setting.

 

Once selected the values are highlighted and remembers their last selection when the dialog reappears.

 

I do not use list boxes too often, But in this case it seemed like a nice change. Boy was I wrong.

Link to comment
Share on other sites

Buzzard, its not too difficult, list boxes work in the same way as popup_lists (oh, and it should've been "0")

 

An Example:

 

(defun c:test ( / dc f lst item )
 (cond
   (
     (or
       (<= (setq dc (load_dialog "ListBox.dcl")) 0)
       (not (new_dialog "test" dc))
     )
   )
   (t
     (start_list "lst")
     (mapcar (function add_list) (setq lst '("Item1" "Item2" "Item3")))
     (end_list)

     (setq item (set_tile "lst" "0"))

     (action_tile "lst" "(setq item $value)")

     (setq f (start_dialog) dc (unload_dialog dc))

     (if (= f 1)
       (alert
         (strcat "You Selected: "
           (nth (atoi item) lst)
         )
       )
     )
   )
 )
 (princ)
)

test : dialog { label = "List_Box Example";
 spacer;
 : list_box { label = "Select Item"; key = "lst"; }
 spacer;
 ok_cancel;
}
            

Save the DCL as ListBox.dcl

Link to comment
Share on other sites

Here is the incomplete code with dcl. It will run, But is not set to do anything as of yet. But you will see what I am describing.

 

See attached.

AF.zip

Document1.JPG

Link to comment
Share on other sites

Buzzard, its not too difficult, list boxes work in the same way as popup_lists (oh, and it should've been "0")

 

An Example:

 

(defun c:test ( / dc f lst item )
 (cond
   (
     (or
       (<= (setq dc (load_dialog "ListBox.dcl")) 0)
       (not (new_dialog "test" dc))
     )
   )
   (t
     (start_list "lst")
     (mapcar (function add_list) (setq lst '("Item1" "Item2" "Item3")))
     (end_list)

     (setq item (set_tile "lst" "0"))

     (action_tile "lst" "(setq item $value)")

     (setq f (start_dialog) dc (unload_dialog dc))

     (if (= f 1)
       (alert
         (strcat "You Selected: "
           (nth (atoi item) lst)
         )
       )
     )
   )
 )
 (princ)
)

test : dialog { label = "List_Box Example";
 spacer;
 : list_box { label = "Select Item"; key = "lst"; }
 spacer;
 ok_cancel;
}
            

Save the DCL as ListBox.dcl

I tried it with 0 and have the same issue.

Link to comment
Share on other sites

Check my example.

 

 

I just tried this:

 

           (setq AF:CLASS# (set_tile "CLASS"  "0"))
          (setq AF:PSIZ#  (set_tile "PSIZ"   "0")) 

 

Size highlights now, But not Class.

Link to comment
Share on other sites

I only set the variables so that the variables have the tile_value if no item is selected before the user hits OK.

 

The set_tile statements are the functions that highlight the list_box items - there isn't too much that can go wrong.

Link to comment
Share on other sites

I only set the variables so that the variables have the tile_value if no item is selected before the user hits OK.

 

The set_tile statements are the functions that highlight the list_box items - there isn't too much that can go wrong.

Ok, I moved the function calls for the List Extraction above the set_tile calls and it works now.

 

 

Thanks a lot, Thats the ticket.

 

        (t (start_list "CLASS" 3)(mapcar 'add_list CLASS_LST)(end_list)
          (start_list "PSIZ"  3)(mapcar 'add_list PSIZ_LST) (end_list)
          (AF_MT)
          (AF_CLU)
          (AF_SLU)
          (set_tile AF:FTYP$ "1")
          (set_tile AF:VIEW$ "1")
          (set_tile AF:FACE$ "1")
          (set_tile AF:DUNT$ "1")
          (set_tile "DF" AF:DF$)
          (setq AF:CLASS# (set_tile "CLASS" "0"))
          (setq AF:PSIZ#  (set_tile "PSIZ"  "0")) 

Link to comment
Share on other sites

Lee,

 

I am still seeing some quirky things happening with this arrangement. I am sure you gave a correct procedure to use. I will look over the sample code more completely and experiment a bit.

 

I will let you know what I find.

Link to comment
Share on other sites

Lee,

 

After careful review of looking over your code and seeing how I could apply it to mine, I found that these are just two different situations. The code you are showing has one list with nothing controlling its contents such as a radio button or another list. My situation has radio buttons controlling the contents of the first list and the first list contolling the contents of the second list. Each time something is done to any of these controllers the highlighting disappears. There must be another way to do this, But nothing comes to mind. I have been changing this code around for days just to get past these obstacles. I guess i will let this one rest a while till I can find something similar to this situation.

 

Thanks for your help anyway,

The Buzzard

Link to comment
Share on other sites

Hi Buzzard, I posted my example to be the simplest possible - I shall try to post an example that would apply to your situation. :)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...