From 0a9f5ec01c64f0d4935098e9e591fba69be96920 Mon Sep 17 00:00:00 2001 From: Richard Wilkes Date: Sat, 21 Sep 2024 18:15:53 -0700 Subject: [PATCH] Allow window options to be passed to NewDialog() --- dialog.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/dialog.go b/dialog.go index b10abb44..48d6f7ac 100644 --- a/dialog.go +++ b/dialog.go @@ -72,7 +72,9 @@ type Dialog struct { } // NewDialog creates a new standard dialog. To show the dialog you must call .RunModal() on the returned dialog. -func NewDialog(icon Drawable, iconInk Ink, msgPanel Paneler, buttonInfo []*DialogButtonInfo) (*Dialog, error) { +// 'windowOptions' are additional options to be passed to the Window constructor for the dialog. The dialog will be +// always have te FloatingWindowOption() set. +func NewDialog(icon Drawable, iconInk Ink, msgPanel Paneler, buttonInfo []*DialogButtonInfo, windowOptions ...WindowOption) (*Dialog, error) { d := &Dialog{buttons: make(map[int]*buttonData)} var frame Rect if focused := ActiveWindow(); focused != nil { @@ -80,7 +82,11 @@ func NewDialog(icon Drawable, iconInk Ink, msgPanel Paneler, buttonInfo []*Dialo } else { frame = PrimaryDisplay().Usable } - d.wnd, d.err = NewWindow("", FloatingWindowOption()) + opts := []WindowOption{FloatingWindowOption()} + if len(windowOptions) > 0 { + opts = append(opts, windowOptions...) + } + d.wnd, d.err = NewWindow("", opts...) if d.err != nil { return nil, errs.NewWithCause("unable to create dialog", d.err) }