Added ability to prevent closing the app when the view is displayed

This commit is contained in:
Maarten Heremans 2024-08-12 14:37:42 +02:00
parent ce11540123
commit 40dad494d9
3 changed files with 11 additions and 1 deletions

View File

@ -148,3 +148,7 @@ func (v *BaseView) RegisterResizeCallback(cb ResizeCallbackFn) {
func (v *BaseView) RegisterMoveCallback(cb MoveCallbackFn) { func (v *BaseView) RegisterMoveCallback(cb MoveCallbackFn) {
v.ScreenHandler.RegisterMoveCallback(cb) v.ScreenHandler.RegisterMoveCallback(cb)
} }
func (v BaseView) PreventClose() bool {
return false
}

View File

@ -5,11 +5,11 @@ import (
"fmt" "fmt"
"io/fs" "io/fs"
"gitea.hevanto-it.com/hevanto/ui/screen"
"fyne.io/fyne/v2" "fyne.io/fyne/v2"
"fyne.io/fyne/v2/data/binding" "fyne.io/fyne/v2/data/binding"
"fyne.io/fyne/v2/dialog" "fyne.io/fyne/v2/dialog"
"fyne.io/fyne/v2/widget" "fyne.io/fyne/v2/widget"
"gitea.hevanto-it.com/hevanto/ui/screen"
"github.com/google/uuid" "github.com/google/uuid"
"github.com/nicksnyder/go-i18n/v2/i18n" "github.com/nicksnyder/go-i18n/v2/i18n"
) )
@ -256,6 +256,10 @@ func (d *BaseDialog) GetCanvasObject() fyne.CanvasObject {
return d.CanvasObj return d.CanvasObj
} }
func (d BaseDialog) PreventClose() bool {
return false
}
type FormDialogItemsFn func() []*widget.FormItem type FormDialogItemsFn func() []*widget.FormItem
type FormDialog struct { type FormDialog struct {

View File

@ -54,4 +54,6 @@ type View interface {
OnHide() OnHide()
GetCanvasObject() fyne.CanvasObject GetCanvasObject() fyne.CanvasObject
PreventClose() bool
} }