close image popup and add to playlist dialog on escape
This commit is contained in:
@@ -42,6 +42,7 @@ func (m Controller) ShowPopUpImage(img image.Image) {
|
||||
w := s.Width * 0.8
|
||||
popS = fyne.NewSize(w, w*(1/asp))
|
||||
}
|
||||
util.ClosePopUpOnEscape(pop)
|
||||
pop.Resize(popS)
|
||||
pop.ShowAtPosition(fyne.NewPos(
|
||||
(s.Width-popS.Width)/2,
|
||||
@@ -120,6 +121,7 @@ func (m Controller) DoAddTracksToPlaylistWorkflow(trackIDs []string) {
|
||||
|
||||
dlg := dialogs.NewAddToPlaylistDialog("Add to Playlist", plNames)
|
||||
pop := widget.NewModalPopUp(dlg, m.MainWindow.Canvas())
|
||||
util.ClosePopUpOnEscape(pop)
|
||||
dlg.OnCanceled = pop.Hide
|
||||
dlg.OnSubmit = func(playlistChoice int, newPlaylistName string) {
|
||||
pop.Hide()
|
||||
|
||||
+8
-5
@@ -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()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user