mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-05 17:35:36 +00:00
widget/material: add hovered to RadioButton
Signed-off-by: Egon Elbre <egonelbre@gmail.com>
This commit is contained in:
+8
-1
@@ -10,7 +10,8 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type Enum struct {
|
type Enum struct {
|
||||||
Value string
|
Value string
|
||||||
|
Hovered string
|
||||||
|
|
||||||
changed bool
|
changed bool
|
||||||
|
|
||||||
@@ -56,6 +57,12 @@ func (e *Enum) Layout(gtx layout.Context, key string) layout.Dimensions {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if e.Hovered == key {
|
||||||
|
e.Hovered = ""
|
||||||
|
}
|
||||||
|
if clk.Hovered() {
|
||||||
|
e.Hovered = key
|
||||||
|
}
|
||||||
clk.Add(gtx.Ops)
|
clk.Add(gtx.Ops)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ func RadioButton(th *Theme, group *widget.Enum, key, label string) RadioButtonSt
|
|||||||
|
|
||||||
// Layout updates enum and displays the radio button.
|
// Layout updates enum and displays the radio button.
|
||||||
func (r RadioButtonStyle) Layout(gtx layout.Context) layout.Dimensions {
|
func (r RadioButtonStyle) Layout(gtx layout.Context) layout.Dimensions {
|
||||||
dims := r.layout(gtx, r.Group.Value == r.Key, false)
|
dims := r.layout(gtx, r.Group.Value == r.Key, r.Group.Hovered == r.Key)
|
||||||
gtx.Constraints.Min = dims.Size
|
gtx.Constraints.Min = dims.Size
|
||||||
r.Group.Layout(gtx, r.Key)
|
r.Group.Layout(gtx, r.Key)
|
||||||
return dims
|
return dims
|
||||||
|
|||||||
Reference in New Issue
Block a user