Skip to content
This repository was archived by the owner on Dec 31, 2022. It is now read-only.

Commit ebf5e2d

Browse files
authored
Merge pull request #143 from JetSetIlly/RadioButtonInt
added RadioButtonInt()
2 parents 2d2d232 + 1f6cbe5 commit ebf5e2d

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

Widgets.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,26 @@ func RadioButton(id string, active bool) bool {
113113
return C.iggRadioButton(idArg, castBool(active)) != 0
114114
}
115115

116+
// RadioButtonInt modifies integer v. Returns true if it is selected.
117+
//
118+
// The radio button will be set if v == button. Useful for groups of radio
119+
// buttons. In the example below, "radio b" will be selected.
120+
//
121+
// v := 1
122+
// imgui.RadioButtonInt("radio a", &v, 0)
123+
// imgui.RadioButtonInt("radio b", &v, 1)
124+
// imgui.RadioButtonInt("radio c", &v, 2)
125+
//
126+
func RadioButtonInt(id string, v *int, button int) bool {
127+
idArg, idFin := wrapString(id)
128+
defer idFin()
129+
ok := C.iggRadioButton(idArg, castBool(button == *v)) != 0
130+
if ok {
131+
*v = button
132+
}
133+
return ok
134+
}
135+
116136
// Bullet draws a small circle and keeps the cursor on the same line.
117137
// Advance cursor x position by TreeNodeToLabelSpacing(), same distance that TreeNode() uses.
118138
func Bullet() {

0 commit comments

Comments
 (0)