Confirm Dialog
A Confirm Dialog in Fyne is a pop-up window that asks the user to confirm an action, usually with “OK” and “Cancel” buttons.
Show Code
package main
import ( "fmt"
"fyne.io/fyne/v2" "fyne.io/fyne/v2/app" "fyne.io/fyne/v2/dialog" "fyne.io/fyne/v2/widget")
func main() { a := app.New() w := a.NewWindow("Confirm Dialog")
btn := widget.NewButton("Delete Item", func() { dialog.NewConfirm("Confirm Delete", "Are you sure you want to delete this item?", func(confirmed bool) { if confirmed { fmt.Println("Item deleted") } else { fmt.Println("Action cancelled") } }, w).Show() })
w.SetContent(btn) w.Resize(fyne.NewSize(300, 150)) w.ShowAndRun()}