Popups package uses the new modal system
This commit is contained in:
parent
d710d13f0d
commit
a2c0ff5f4c
@ -24,6 +24,7 @@ func run () {
|
|||||||
infoButton.OnClick (func () {
|
infoButton.OnClick (func () {
|
||||||
popups.NewDialog (
|
popups.NewDialog (
|
||||||
popups.DialogKindInfo,
|
popups.DialogKindInfo,
|
||||||
|
window,
|
||||||
"Information",
|
"Information",
|
||||||
"You are wacky")
|
"You are wacky")
|
||||||
})
|
})
|
||||||
@ -34,6 +35,7 @@ func run () {
|
|||||||
questionButton.OnClick (func () {
|
questionButton.OnClick (func () {
|
||||||
popups.NewDialog (
|
popups.NewDialog (
|
||||||
popups.DialogKindQuestion,
|
popups.DialogKindQuestion,
|
||||||
|
window,
|
||||||
"The Big Question",
|
"The Big Question",
|
||||||
"Are you real?",
|
"Are you real?",
|
||||||
popups.Button { "Yes", func () { } },
|
popups.Button { "Yes", func () { } },
|
||||||
@ -46,6 +48,7 @@ func run () {
|
|||||||
warningButton.OnClick (func () {
|
warningButton.OnClick (func () {
|
||||||
popups.NewDialog (
|
popups.NewDialog (
|
||||||
popups.DialogKindWarning,
|
popups.DialogKindWarning,
|
||||||
|
window,
|
||||||
"Warning",
|
"Warning",
|
||||||
"They are fast approaching.")
|
"They are fast approaching.")
|
||||||
})
|
})
|
||||||
@ -55,6 +58,7 @@ func run () {
|
|||||||
errorButton.OnClick (func () {
|
errorButton.OnClick (func () {
|
||||||
popups.NewDialog (
|
popups.NewDialog (
|
||||||
popups.DialogKindError,
|
popups.DialogKindError,
|
||||||
|
window,
|
||||||
"Error",
|
"Error",
|
||||||
"There is nowhere left to go.")
|
"There is nowhere left to go.")
|
||||||
})
|
})
|
||||||
|
@ -27,15 +27,21 @@ type Button struct {
|
|||||||
OnPress func ()
|
OnPress func ()
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewDialog creates a new dialog window and returns it.
|
// NewDialog creates a new modal dialog window and returns it. If parent is nil,
|
||||||
|
// the dialog will just be a normal window
|
||||||
func NewDialog (
|
func NewDialog (
|
||||||
kind DialogKind,
|
kind DialogKind,
|
||||||
|
parent elements.Window,
|
||||||
title, message string,
|
title, message string,
|
||||||
buttons ...Button,
|
buttons ...Button,
|
||||||
) (
|
) (
|
||||||
window elements.Window,
|
window elements.Window,
|
||||||
) {
|
) {
|
||||||
|
if parent == nil {
|
||||||
window, _ = tomo.NewWindow(2, 2)
|
window, _ = tomo.NewWindow(2, 2)
|
||||||
|
} else {
|
||||||
|
window, _ = parent.NewModal(2, 2)
|
||||||
|
}
|
||||||
window.SetTitle(title)
|
window.SetTitle(title)
|
||||||
|
|
||||||
container := containers.NewContainer(basicLayouts.Dialog { true, true })
|
container := containers.NewContainer(basicLayouts.Dialog { true, true })
|
||||||
|
Reference in New Issue
Block a user