Topper Harley
Topper Harley

Reputation: 12374

How to check a radio button programmatically?

I set up a dialog with 2 radio buttons, and use a boolean to check them programmatically.

    // Not working day radio button
    final Button notWorkingDayButton = new Button(mSelectedDayGroup, SWT.RADIO);
    notWorkingDayButton.setSelection(isWorkingDay);
    notWorkingDayButton.setText("Jour chômé"+(isHoliday ? deft : ""));

    // Working day radio button
    final Button workingDayButton = new Button(mSelectedDayGroup, SWT.RADIO);
    workingDayButton.setText("Jour travaillé"+(isHoliday ? "" : deft));
    workingDayButton.setSelection(!isWorkingDay);

As you can see, they use the same boolean so they always have opposed states.

Here's how it looks like if isWorkingDay is true: isWorkingDay=true

Here's how it looks like if isWorkingDay is false: isWorkingDay=false

As you can see the first radio stays somewhat enabled. I want the first one to be completely disabled and the second one completely enabled when isWorkingDay = false.

Upvotes: 0

Views: 767

Answers (1)

Frettman
Frettman

Reputation: 2271

I don't have a Mac but this looks like the keyboard focus to me. There is no "somewhat enabled" state for radio buttons.

Upvotes: 2

Related Questions