Radio Buttons

Radio Buttons

angiegauthier
Enthusiast Enthusiast
834 Views
8 Replies
Message 1 of 9

Radio Buttons

angiegauthier
Enthusiast
Enthusiast

I'm running into an issue where I have a row of radio buttons. Typically, the first button is the most common option, but in one specific option, I have to grey out the first button. When I do that, and the user tabs through the dialog, it skips the whole row, rather than going to the second option in the radio row. I've tried is_tab_stop, but that doesn't seem to work.

Is there some way to get it to tab to the second radio button when the first one is greyed out? 

 

thanks for your help everyone!

0 Likes
Accepted solutions (1)
835 Views
8 Replies
Replies (8)
Message 2 of 9

paullimapa
Mentor
Mentor
0 Likes
Message 3 of 9

angiegauthier
Enthusiast
Enthusiast

I hadn't thought of that. Thanks Paul. It does select the button, but it's not an ideal option in this case, because it still makes the users do something different than what they're used to doing (I've got some speedy cad users over here who are pretty particular about the way things flow) I'd still like to see if anyone has any other solutions before I go with this.

 

Angie

0 Likes
Message 4 of 9

Sea-Haven
Mentor
Mentor
Accepted solution

Does (set_tile butname "1") after 1st button is set to greyout, which would be second radio button making it current.  Very little testing but seemed to work must pick highlited button or another, may be just my dcl code.

 

0 Likes
Message 5 of 9

komondormrex
Mentor
Mentor

add dummy radio button to be the first and always first in radio row to have tab stop on radio row regardless of modes of other radio buttons.

0 Likes
Message 6 of 9

Moshe-A
Mentor
Mentor

@angiegauthier hi,

 

Maybe this can be your solution 🤣

 

instead of using radio_row  /  radio_column tiles, define a custom radio buttons with toggles and this is my sample

 

enjoy

Moshe

 

dcl_settings : default_dcl_settings { audit_level = 0; }

// reference tile
custom_radio_button : toggle {
  value = "0";
  height = 1.25;
}

// reference tile
custom_radio_row : boxed_row {
  label = "Custom radio row";
  children_fixed_width = true;
  
  : custom_radio_button {
    label = "&Left";
    key = "left";
  }
  : custom_radio_button {
    label = "&Right";
    key = "right";
  }
  :  custom_radio_button {
    label = "&Top";
    key = "top";
  }
  :  custom_radio_button {
    label = "&Bottom";
    key = "bottom";
  }
} // custom_radio_row

custom_radio_column : boxed_column {
  label = "Custom radio column";
  children_fixed_height = true;
  
  : custom_radio_button {
    label = "&One";
    key = "one";
  }
  : custom_radio_button {
    label = "&Two";
    key = "two";
  }
  :  custom_radio_button {
    label = "&three";
    key = "three";
  }
  :  custom_radio_button {
    label = "&Four";
    key = "four";
  }
} // custom_radio_column

sample1 : dialog {			
 label = "Sample Custom Radio buttons" ;

 custom_radio_row;
 spacer_1;
 custom_radio_column;
 
 ok_cancel;
}

 

(defun C:TEST1 (/ ctrl_toggle get_radio_value  ctrl_accept ; local functions
		  TOGGLES_ROW TOGGLES_COLUMN dcl_id what_next selkey1 selkey2)

 ; callback 
 (defun ctrl_toggle (selkey TOGGLES / key)
  (foreach key (vl-remove selkey TOGGLES)
   (set_tile key "0")
  )  
 ); ctrl_toggle

  
 ; return selected key or "" if none assigned 
 (defun get_radio_value (TOGGLES / v)
  (if (not (setq v (vl-some (function (lambda (key) (if (eq (get_tile key) "1") key))) TOGGLES))) "none" v)
 ); get_radio_value

  
 (defun ctrl_accept ()
  (setq selkey1 (get_radio_value TOGGLES_ROW))
  (setq selkey2 (get_radio_value TOGGLES_COLUMN))
  (done_dialog 1) 
 ); ctrl_accept
  
  
 ; here start (c:test1)
 (setq TOGGLES_ROW    '("left" "right" "top"   "bottom")) ; const
 (setq TOGGLES_COLUMN '("one"  "two"   "three" "four"  )) ; const
  
 (if (setq dcl_id (load_dialog "test1"))
  (progn
   (setq what_next 2)
       
   (While (> what_next 1)
    (if (not (new_dialog "sample1" dcl_id "" '(-1 -1)))	; open dialog
     (exit)
    )

    (foreach key TOGGLES_ROW 
     (action_tile key "(ctrl_toggle $key TOGGLES_ROW)")
    )  
    (foreach key TOGGLES_COLUMN 
     (action_tile key "(ctrl_toggle $key TOGGLES_COLUMN)")
    )  

    (action_tile "accept" "(ctrl_accept)")
     
    (setq what_next (start_dialog)) ; start dialog box

    (cond
     ((= what_next 0)
      nil
     ); case
     ((= what_next 1)
      (terpri)
      (princ (strcat "Selected row button: " selkey1))
      (terpri)
      (princ (strcat "Selected column button: " selkey2))
     ); case
    ); cond
     
   ); while
   (setq dcl_id (unload_dialog dcl_id))
  
  ); progn
 ); if

 (princ)
); c:test1

 

 

 

 

 

0 Likes
Message 7 of 9

scot-65
Advisor
Advisor
Without looking at your code, are you initializing the radio row?
A radio button (as most other tiles) has 3 values: 0, 1, and nil.
Not initializing may be why tab stop is skipping over the radio button.
Initialize the radio row first, then set the desired radio button to "0".

:radio_row {key="Rad0";
:radio_button {key="Rad1"; label="Salt";}
:radio_button {key="Rad2"; label="Pepper";}
}

(set_tile "Rad0" "Rad2")
(mode_tile "Rad1" 1)
(set_tile "Rad2" "0")

untested.

Scot-65
A gift of extraordinary Common Sense does not require an Acronym Suffix to be added to my given name.

0 Likes
Message 8 of 9

angiegauthier
Enthusiast
Enthusiast

Thanks so much @Sea-Haven , that seems to work and be the simplest solution. 

 

thanks everyone for your help on this one!!

 

Angie

0 Likes
Message 9 of 9

angiegauthier
Enthusiast
Enthusiast

@Moshe-A thanks. While I'm going with a different work around in this case, I may look into custom radio buttons further at some point in time.

 

Angie

0 Likes