# How to disable the default selection of a radio button?

**URL:** <https://www.ruby-forum.com/t/how-to-disable-the-default-selection-of-a-radio-button/157412>\
**Category:** Ruby\
**Created:** [January 10, 2009, 9:52pm UTC](https://www.ruby-forum.com/t/how-to-disable-the-default-selection-of-a-radio-button/157412 "2009-01-10T21:52:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![alex-osu3](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/13edae/32.png) [@alex-osu3](https://www.ruby-forum.com/u/alex-osu3)\
**Post date:** [January 10, 2009, 9:52pm UTC](https://www.ruby-forum.com/t/how-to-disable-the-default-selection-of-a-radio-button/157412/1 "2009-01-10T21:52:24Z")

</div>

Hi all,

I use FXRuby to create 5 radio buttons and tie them to FXDataTarget.  
When I run the codes a defautl button is always selected. Is it  
possible to disable this feature so that no button is chosen at the  
first run?

Thanks,

Li

---

<div class="post-metadata">

**Author:** ![alex-osu3](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/13edae/32.png) [@alex-osu3](https://www.ruby-forum.com/u/alex-osu3)\
**Post date:** [January 12, 2009, 4:48pm UTC](https://www.ruby-forum.com/t/how-to-disable-the-default-selection-of-a-radio-button/157412/2 "2009-01-12T16:48:47Z")

</div>

On Sat, Jan 10, 2009 at 2:51 PM, Li Chen [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I use FXRuby to create 5 radio buttons and tie them to FXDataTarget.  
> When I run the codes a defautl button is always selected. Is it  
> possible to disable this feature so that no button is chosen at the  
> first run?

Sure, just initialize the FXDataTarget to some value that doesn’t  
correspond to _any_ of the radio buttons, e.g.

```
data_target = FXDataTarget.new(-1)
FXRadioButton.new(..., :target => data_target, :selector =>

```

FXDataTarget::ID\_OPTION+0, …)  
FXRadioButton.new(…, :target =\> data\_target, :selector =\>  
FXDataTarget::ID\_OPTION+1, …)  
FXRadioButton.new(…, :target =\> data\_target, :selector =\>  
FXDataTarget::ID\_OPTION+2, …)  
FXRadioButton.new(…, :target =\> data\_target, :selector =\>  
FXDataTarget::ID\_OPTION+3, …)  
FXRadioButton.new(…, :target =\> data\_target, :selector =\>  
FXDataTarget::ID\_OPTION+4, …)

Hope this helps,

Lyle

---

<div class="post-metadata">

**Author:** ![alex-osu3](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/13edae/32.png) [@alex-osu3](https://www.ruby-forum.com/u/alex-osu3)\
**Post date:** [January 13, 2009, 12:10am UTC](https://www.ruby-forum.com/t/how-to-disable-the-default-selection-of-a-radio-button/157412/3 "2009-01-13T00:10:43Z")

</div>

Lyle J. wrote:

> Sure, just initialize the FXDataTarget to some value that doesn’t  
> correspond to _any_ of the radio buttons, e.g.

Thanks. But where can I find this tip in its API?

Li
