close image popup and add to playlist dialog on escape

This commit is contained in:
Drew Weymouth
2023-03-02 20:27:08 -08:00
parent 27ed8216f3
commit 595d9116f0
2 changed files with 10 additions and 5 deletions
+8 -5
View File
@@ -27,11 +27,6 @@ func ImageAspect(im image.Image) float32 {
return float32(b.Max.X-b.Min.X) / float32(b.Max.Y-b.Min.Y)
}
type PopUpProvider interface {
CreatePopUp(fyne.CanvasObject) *widget.PopUp
WindowSize() fyne.Size
}
func RichTextSegsFromHTMLString(s string) []widget.RichTextSegment {
tokr := html.NewTokenizer(strings.NewReader(s))
var segs []widget.RichTextSegment
@@ -59,3 +54,11 @@ func RichTextSegsFromHTMLString(s string) []widget.RichTextSegment {
return segs
}
func ClosePopUpOnEscape(pop *widget.PopUp) {
pop.Canvas.SetOnTypedKey(func(e *fyne.KeyEvent) {
if e.Name == fyne.KeyEscape {
pop.Hide()
}
})
}