mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-02 16:06:19 +00:00
widget,widget/material: make Clickable widgets focusable
This change adds focus and keyboard control to Clickable widgets. They now consider a press of the enter or return key equivalent to a click. To keep the change simple, the focus indication is the same as the hover indication. References: https://todo.sr.ht/~eliasnaur/gio/195 References: https://github.com/tailscale/tailscale/issues/1611 Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
@@ -99,7 +99,7 @@ func (s SwitchStyle) Layout(gtx layout.Context) layout.Dimensions {
|
||||
return clip.Ellipse(b).Op(gtx.Ops)
|
||||
}
|
||||
// Draw hover.
|
||||
if s.Switch.Hovered() {
|
||||
if s.Switch.Hovered() || s.Switch.Focused() {
|
||||
r := 1.7 * thumbRadius
|
||||
background := f32color.MulAlpha(s.Color.Enabled, 70)
|
||||
paint.FillShape(gtx.Ops, background, circle(thumbRadius, thumbRadius, r))
|
||||
|
||||
Reference in New Issue
Block a user