How to deselect Option Button

Started by kruuger, March 19, 2010, 05:40:24 PM

Previous topic - Next topic

kruuger

Hello

I got few Option Buttons. OnInitialize i set value for one of them.
Code (autolisp) Select
(dcl_Control_SetValue Shortcuts_SHORT_OptionButton1 1)

Next time OnInitialize i want to select next Option Button 2 but dialog box remember also first OptionButton1.

My question is, so every time when i close my dialog i need to change value all of Option Button to 0?

Thanks

Kerry

#1


For an Option Button 0 = Unchecked; 1 = Checked
Code (autolisp) Select
(dcl_Control_SetValue Shortcuts_SHORT_OptionButton1 1)

[/quote]

For an OptionList nominate the Selected indexItem (zero based ie 0 = Item1 )
Code (autolisp) Select
(dcl_Control_SetCurrentSelection Untitled_Form1_OptionList1 < NewValue [as Long] > )
Perfection is not optional.
My other home is TheSwamp

Kerry

#2
If  the OptionButton1  was set last time you used it and you want OptionButton2 on next time :
Perhaps try something like in the initialize Event :

Code (autolisp) Select


(cond ((= 1 (dcl_Control_GetValue Shortcuts_SHORT_OptionButton1))
      (dcl_Control_SetValue Shortcuts_SHORT_OptionButton1 0)
      (dcl_Control_SetValue Shortcuts_SHORT_OptionButton2 1)
     )
     ((= 1 (dcl_Control_GetValue Shortcuts_SHORT_OptionButton2))
      (dcl_Control_SetValue Shortcuts_SHORT_OptionButton2 0)
      (dcl_Control_SetValue Shortcuts_SHORT_OptionButton3 1)
     )
     ((= 1 (dcl_Control_GetValue Shortcuts_SHORT_OptionButton3))
      (dcl_Control_SetValue Shortcuts_SHORT_OptionButton3 0)
      (dcl_Control_SetValue Shortcuts_SHORT_OptionButton4 1)
     )
     ((= 1 (dcl_Control_GetValue Shortcuts_SHORT_OptionButton4))
      (dcl_Control_SetValue Shortcuts_SHORT_OptionButton4 0)
      (dcl_Control_SetValue Shortcuts_SHORT_OptionButton4 1)
     )
     ((= 1 (dcl_Control_GetValue Shortcuts_SHORT_OptionButton5))
      (dcl_Control_SetValue Shortcuts_SHORT_OptionButton5 0)
      (dcl_Control_SetValue Shortcuts_SHORT_OptionButton1 1)
     )
     ;; in case none are on
     (T (dcl_Control_SetValue Shortcuts_SHORT_OptionButton1 1))
)


Perfection is not optional.
My other home is TheSwamp

Kerry

#3
Quote.... when i close my dialog i need to change value all of Option Button to 0

Perhaps try something like this In the OnClose Event :
Code (autolisp) Select


;;(foreach Control '(Shortcuts_SHORT_OptionButton1 ;<~
(foreach Control (LIST Shortcuts_SHORT_OptionButton1
                  Shortcuts_SHORT_OptionButton2
                  Shortcuts_SHORT_OptionButton3
                  Shortcuts_SHORT_OptionButton4
                  Shortcuts_SHORT_OptionButton5
                 )
 (dcl_Control_SetValue Control 0)
)


[edit]Quoted array Changed to LIST
Perfection is not optional.
My other home is TheSwamp

kruuger

These FOREACH and COND are very nice solution  :)
I like it :)

Thanks Kerry

kruuger

foreach works but like this:

Code (autolisp) Select
(foreach Control (LIST Shortcuts_SHORT_OptionButton1  
                   Shortcuts_SHORT_OptionButton2  
                   Shortcuts_SHORT_OptionButton3  
                   Shortcuts_SHORT_OptionButton4  
                   Shortcuts_SHORT_OptionButton5  
                  )  
  (dcl_Control_SetValue Control 0)  
)  

Kerry

Yes, we'd need to use LIST rather than QUOTE so that the Button ID variables will be evaluated.

Perfection is not optional.
My other home is TheSwamp