You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
668 B
Go

package input
import (
"github.com/vugu/vugu"
)
// RadioButton provides an option that the user can select.
// A group of RadioButtons is defined when they share a data binding.
type RadioButton struct {
AttrMap vugu.AttrMap
Bind ValueBinder // Binds the current selected key to some variable.
Key string // The key that this RadioButton represents as a string.
}
func (c *RadioButton) isChecked() bool {
if c.Bind != nil {
return c.Bind.StringValue() == c.Key
}
return false
}
func (c *RadioButton) handleChange(event vugu.DOMEvent) {
if c.Bind == nil {
return
}
if event.PropBool("target", "checked") {
c.Bind.SetStringValue(c.Key)
}
}