Author Topic: Radio_button controls and list boxes.  (Read 1664 times)

0 Members and 1 Guest are viewing this topic.

jlogan02

  • Bull Frog
  • Posts: 327
Radio_button controls and list boxes.
« on: February 13, 2020, 07:20:59 PM »
When user pics Draw Line the "Select Layer" List_box would only list LINE layers.
When user selects Add Text the "Select Layer" List_box would change to show TEXT Layers or Text Style.
Then there would be a choice for selecting color of those objects before placing.

I've all of it working except the color part (not there yet) and the changing the list box contents
This snippet of code handles a text box opening or closing based on selection of a radio button On/Off

Code - Auto/Visual Lisp: [Select]
  1. (action_tile "radio_button_ON" "(mode_tile \"text_box_1\" 0)")
  2. (action_tile "radio_button_OFF" "(mode_tile \"text_box_1\" 1)")

Can this same approach be used for my needs?


J. Logan
ACAD 2018

I am one with the Force and the Force is with me.
AutoCAD Map 2018 Windows 10

BIGAL

  • Swamp Rat
  • Posts: 1409
  • 40 + years of using Autocad
Re: Radio_button controls and list boxes.
« Reply #1 on: February 16, 2020, 04:49:33 AM »
Try the inbuilt choose color (acad_colordlg 256) google the command for options like the number.
A man who never made a mistake never made anything

snownut2

  • Swamp Rat
  • Posts: 971
  • Bricscad 22 Ultimate
Re: Radio_button controls and list boxes.
« Reply #2 on: February 17, 2020, 10:23:46 PM »
You really only need one action_tile, put the radio buttons in a radio_column and assign a key to the column.  Then rename your two radio button keys to something like "line" & "text".

Then when you have the action tile be something like (setq action $value)

Then the value of the action variable becomes line or text depending on which button is selected. 

Then with an if statement you can repopulate the list with correct info. 

Using this method you can control many radio buttons with one action tile.

snownut2

  • Swamp Rat
  • Posts: 971
  • Bricscad 22 Ultimate
Re: Radio_button controls and list boxes.
« Reply #3 on: February 18, 2020, 08:37:38 AM »
This is untested but should work...

Code - Auto/Visual Lisp: [Select]
  1. ;  DCL Bit
  2. : boxed_row {
  3. :   radio_column { key = "action" ; }
  4. :     radio_button { label = "Draw Line" ; key = "linel" ; }
  5. :     radio_button { label = "Add Text"  ;  key = "textl" ; }
  6. :   }
  7. :   column {
  8. :     text { label = "Select Layer" ;   }
  9. :     list_box { key = "layname"  ;    }
  10. :   }
  11. : }
  12.  
  13.  
  14. ;  LISP Bit (Due to BricsCads habit of selecting 1st radio option, need to pre-define values in case user doesn't select radio button)
  15.  
  16.   linel '("line 1" "line 2" "line 3")
  17.   textl '("text 1" "text 2" "text 3")
  18.   layname (car linel)
  19. )
  20. ; ----- load dcl here -----
  21.  
  22. (start_list "layname")
  23. (mapcar 'add_list linel)
  24. (set_tile "action" "linel")
  25.  
  26. (action_tile "action"  "(start_list \"layname\")(mapcar 'add_list (read $value))(end_list)")
  27. (action_tile "layname" "(set (read $key) (nth (atoi $value) (read(get_tile \"action\"))")
  28.