Custom dialogs
Although the preceding dialogs should cover most of the reasons why you may wish to interrupt the user flow with a pop-up dialog, your app may have additional requirements. To support this, you can insert any content into a custom dialog so that the overall layout is consistent.
To construct a custom dialog, a new parameter and its content must be passed to the constructor function. Any Fyne widget or CanvasObject
can be used in a custom dialog, which includes containers to provide more complex content. To illustrate this, we will use a TextGrid
component:
content := widget.NewTextGrid() content.SetText("Custom content") content.SetStyleRange(0, 7, 0, 14, widget.TextGridStyleWhitespace) dialog.ShowCustom("Custom Dialog", "Cancel", content, win)
The preceding code will generate a custom dialog, as shown here: