如何在 tkd 中轮询一组 RadioButton 小部件(D 语言的 Tinker)

How do I poll a set of RadioButton widgets in tkd (Tinker for the D language)

我为我的 tkd 界面制作了一个 RadioButton 小部件块,它完全按预期工作。但是,tkd 的 RadioButton 的 documentation 没有显示如何确定按下哪个按钮。相反,示例代码只是展示了如何创建一组链接在一起的按钮(即一次只能选择一个按钮)

// The radio button group parent.
auto frame = new Frame()
    .pack();    
auto option1 = new RadioButton(frame, "Foo")
    .setSelectedValue("foo")
    .select()
    .pack();    
auto option2 = new RadioButton(frame, "Bar")
    .setSelectedValue("bar")
    .pack();

CheckButton 小部件与之类似,可以使用其关联的 isChecked() 方法进行轮询,但 RadioButton 似乎没有类似的东西。

如何检查给定的 RadioButton 是否已被选中?

此外,是否有一种简单的方法可以检查 RadioButton 数组中的哪个成员被选中,而无需自己遍历整个集合?

阅读更多文档后,tkd 似乎通过一系列 mixins 实现了此功能。

RadioButton class 实现 here 中描述的值接口。

调用任何关联方法将允许访问整个按钮数组共享的状态变量。例如

option1.getValue(); // Returns "Foo" if option 1 is selected, "Bar" if option 2 is.
option2.getValue(); // Same as above, since the value is shared.
option2.setValue("bar"); //Change value, without changing the selected button.