widget: don't draw Editor selection when not focused

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2022-04-23 15:45:41 +02:00
parent 2381c5ad70
commit 3c45a6d420
+3
View File
@@ -649,6 +649,9 @@ func (e *Editor) layout(gtx layout.Context, content layout.Widget) layout.Dimens
// PaintSelection paints the contrasting background for selected text.
func (e *Editor) PaintSelection(gtx layout.Context) {
if !e.focused {
return
}
cl := textPadding(e.lines)
cl.Max = cl.Max.Add(e.viewSize)
defer clip.Rect(cl).Push(gtx.Ops).Pop()