TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Visual DCL Programming => Topic started by: vicoco on May 12, 2021, 11:27:07 AM

Title: Disabling list box in DCL dialog
Post by: vicoco on May 12, 2021, 11:27:07 AM
I'm sure it'll be so simple, but I can't do it...

Can I enable/disable a list box in a dialog box depending on a toggle is off/on?
Can I disable a list box using mode_tile? I'm not successful...

I think that the appended example is enough to understand that I want to do:
- if toggle button ("None") is True -> element list will be disabled to avoid selecting items;
- if toggle button is False -> element list will be enabled.

Title: Re: Disabling list box in DCL dialog
Post by: roy_043 on May 12, 2021, 01:30:59 PM
This should work:
Code: [Select]
(mode_tile "tileKey" 1) ; Disable.
(mode_tile "tileKey" 0) ; Enable.
Title: Re: Disabling list box in DCL dialog
Post by: vicoco on May 14, 2021, 06:17:24 AM
This should work:
Code: [Select]
(mode_tile "tileKey" 1) ; Disable.
(mode_tile "tileKey" 0) ; Enable.

It should work, but how??

I use something like this:

Code: [Select]
(if (= (get_tile "togglekey") True)
(mode_tile "listboxkey" 1)
(mode_tile "listboxkey" 0))

I tried to do it directly in the main function.

I tried to defun a new function in this way:
Code: [Select]
(defun DisableList ()
  (if
    (= (get_tile "togglekey") True)
    (mode_tile "listboxkey" 1)
    (mode_tile "listboxkey" 0)
  )
)

and adding the next line in the main function:
Code: [Select]
(action_tile "togglekey" "(DisableList)")
I know that something escapes me, but I can't find the failure (my knowledge is still very low).
Title: Re: Disabling list box in DCL dialog
Post by: roy_043 on May 14, 2021, 07:10:40 AM
The get_tile function returns a string. In the case of a toggle either "0" or "1".
Code - Auto/Visual Lisp: [Select]
  1. (defun DisableList ()
  2.   (if (= (get_tile "togglekey") "1")
  3.     (mode_tile "listboxkey" 1)
  4.     (mode_tile "listboxkey" 0)
  5.   )
  6. )
Title: Re: Disabling list box in DCL dialog
Post by: Lee Mac on May 15, 2021, 07:13:19 PM
Alternatively, you could use this:
Code - Auto/Visual Lisp: [Select]
  1. (action_tile "togglekey" "(mode_tile \"listboxkey\" (atoi $value))")
Title: Re: Disabling list box in DCL dialog
Post by: vicoco on May 18, 2021, 11:05:58 AM
The get_tile function returns a string. In the case of a toggle either "0" or "1".
Code - Auto/Visual Lisp: [Select]
  1. (defun DisableList ()
  2.   (if (= (get_tile "togglekey") "1")
  3.     (mode_tile "listboxkey" 1)
  4.     (mode_tile "listboxkey" 0)
  5.   )
  6. )

The solution was so easy that I feel stupid  :-(

Alternatively, you could use this:
Code - Auto/Visual Lisp: [Select]
  1. (action_tile "togglekey" "(mode_tile \"listboxkey\" (atoi $value))")

Thank you very much, both solutions work perfectly.