mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-05 09:25:38 +00:00
widget: handle hovering of the empty Enum key
Before this change, a radio button with the empty key ("") would be
displayed as hovering if no other button were.
It's still not possible to have no radio buttons selected when one of
them is the empty key. If that's becomes necessary, Enum.Value can be
converted to a *string.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
@@ -36,7 +36,8 @@ func RadioButton(th *Theme, group *widget.Enum, key, label string) RadioButtonSt
|
||||
|
||||
// Layout updates enum and displays the radio button.
|
||||
func (r RadioButtonStyle) Layout(gtx layout.Context) layout.Dimensions {
|
||||
dims := r.layout(gtx, r.Group.Value == r.Key, r.Group.Hovered == r.Key)
|
||||
hovered, hovering := r.Group.Hovered()
|
||||
dims := r.layout(gtx, r.Group.Value == r.Key, hovering && hovered == r.Key)
|
||||
gtx.Constraints.Min = dims.Size
|
||||
r.Group.Layout(gtx, r.Key)
|
||||
return dims
|
||||
|
||||
Reference in New Issue
Block a user