Author Topic: List of checkboxes - is it possible?  (Read 9359 times)

0 Members and 1 Guest are viewing this topic.

mr_nick

  • Guest
List of checkboxes - is it possible?
« on: June 21, 2012, 11:41:34 AM »
Is there a way of creating a list of checkboxes via code rather than hardcoding them into a dialog? I want to create a selection list by passing a list of strings, as per you do with a listbox, but to use an array of checkboxes instead.

I know I can use a multi/toggle listbox but when I did that, the first comment I received back was along the lines of 'Yeah, it works but damn - it's ugly'.

jbuzbee

  • Swamp Rat
  • Posts: 851
Re: List of checkboxes - is it possible?
« Reply #1 on: June 21, 2012, 04:22:02 PM »
All controls have a visibilty property accessible via lisp.  You'll still need to build the form in the OpenDCL editor and use the visibilty property to show / hide the appropriate number of controls.  You can also re-size the form via lisp.

I have done this before so I know it's possible - but not easy.

jb
James Buzbee
Windows 8

owenwengerd

  • Bull Frog
  • Posts: 451
Re: List of checkboxes - is it possible?
« Reply #2 on: June 21, 2012, 04:29:08 PM »
Perhaps a multiple selection list box or list view control would work instead of using check boxes.

mr_nick

  • Guest
Re: List of checkboxes - is it possible?
« Reply #3 on: June 22, 2012, 04:32:08 AM »
OK, no straightforward approach then other than a listbox. Having tried that one already, I know it's simple enough but it met with some 'unfavourable' comments about it's appearance.

I'll have a fiddle and see what I can come up with.

Thanks.

Lee Mac

  • Seagull
  • Posts: 12910
  • London, England
Re: List of checkboxes - is it possible?
« Reply #4 on: June 22, 2012, 08:26:04 AM »
Is standard DCL an option?

Code - Auto/Visual Lisp: [Select]
  1. (defun c:test ( / *error* d e f h i l s )
  2.  
  3.     (defun *error* ( msg )
  4.         (if (< 0 h)
  5.             (unload_dialog h)
  6.         )
  7.         (if (findfile f)
  8.             (vl-file-delete f)
  9.         )
  10.         (if (not (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*"))
  11.             (princ (strcat "\nError: " msg))
  12.         )
  13.         (princ)
  14.     )
  15.    
  16.     (if (setq s (ssget))
  17.         (progn
  18.             (repeat (setq i (sslength s))
  19.                 (setq e (cdr (assoc 0 (entget (ssname s (setq i (1- i)))))))
  20.                 (if (not (member e l))
  21.                     (setq l (cons e l))
  22.                 )
  23.             )
  24.             (if
  25.                 (and
  26.                     (setq f (vl-filename-mktemp nil nil ".dcl"))
  27.                     (setq d (open f "w"))
  28.                     (write-line "test : dialog { label = \"Choose Objects\"; spacer;" d)
  29.                     (foreach x (acad_strlsort l)
  30.                         (write-line (strcat ": toggle { label = \"" x "\"; key = \"" x "\";}") d)
  31.                     )
  32.                     (write-line "ok_only; }" d)
  33.                     (not (setq d (close d)))
  34.                     (< 0 (setq h (load_dialog f)))
  35.                     (new_dialog "test" h)
  36.                 )
  37.                 (start_dialog)
  38.             )
  39.             (if (< 0 h)
  40.                 (unload_dialog h)
  41.             )
  42.             (if (findfile f)
  43.                 (vl-file-delete f)
  44.             )
  45.         )
  46.     )
  47.     (princ)
  48. )

mr_nick

  • Guest
Re: List of checkboxes - is it possible?
« Reply #5 on: June 22, 2012, 08:47:26 AM »
Is standard DCL an option?

Most definitely is. I still have one or two routines which use DCL where a dialog needs to be created on the fly in this manner - albeit in very simplistic ways. I must admit, I do tend to overlook DCL nowadays due to the comparitive simplicity of ODCL but I will certainly revisit it after seeing your example.

Thanks for the inspiration.

owenwengerd

  • Bull Frog
  • Posts: 451
Re: List of checkboxes - is it possible?
« Reply #6 on: June 22, 2012, 01:26:05 PM »
If you must have check boxes, you could use a grid control. The grid control has some idiosyncracies that may make it a bit unwieldy, but it would work in theory.

jbuzbee

  • Swamp Rat
  • Posts: 851
Re: List of checkboxes - is it possible?
« Reply #7 on: June 22, 2012, 02:58:32 PM »
mr_rick,

In the other thread: reactor causing fatal error, what exactly were you wanting to do?  If you want to automatically control the layer the vport goes on why not just edit the mvsetup.lsp?

jb
James Buzbee
Windows 8

Lee Mac

  • Seagull
  • Posts: 12910
  • London, England
Re: List of checkboxes - is it possible?
« Reply #8 on: June 22, 2012, 05:06:51 PM »
Is standard DCL an option?

Most definitely is. I still have one or two routines which use DCL where a dialog needs to be created on the fly in this manner - albeit in very simplistic ways. I must admit, I do tend to overlook DCL nowadays due to the comparitive simplicity of ODCL but I will certainly revisit it after seeing your example.

Thanks for the inspiration.

You're very welcome, hope it helps  :-)

mr_nick

  • Guest
Re: List of checkboxes - is it possible?
« Reply #9 on: June 22, 2012, 09:57:17 PM »
mr_rick,

In the other thread: reactor causing fatal error, what exactly were you wanting to do?  If you want to automatically control the layer the vport goes on why not just edit the mvsetup.lsp?

jb
This topic is not linked to the reactor code. And to that end MVSETUP was not linked to the reactor code, it was purely incidental that somebody in the office started reporting repeated crashes when he was using MVSETUP.

But that is  another tale, for another thread...

mr_nick

  • Guest
Re: List of checkboxes - is it possible?
« Reply #10 on: June 25, 2012, 12:12:52 PM »
If you must have check boxes, you could use a grid control. The grid control has some idiosyncracies that may make it a bit unwieldy, but it would work in theory.

Having had a bit of a play around, the grid control seems to provide the right degree of flexibilty and appearance for my needs but I'm a little concerned by your warning Owen. Would you care to elaborate of what these idiosyncracies are so I know what to look out for or avoid?

owenwengerd

  • Bull Frog
  • Posts: 451
Re: List of checkboxes - is it possible?
« Reply #11 on: June 25, 2012, 01:53:21 PM »
I was referring to possibly undesirable display elements and the editing architecture (i.e. you toggle a checkbox by "editing" its cell, which toggles the image for the cell - not as straightforward as a checkbox control).