Skip to content

Commit

Permalink
Allow window options to be passed to NewDialog()
Browse files Browse the repository at this point in the history
  • Loading branch information
richardwilkes committed Sep 22, 2024
1 parent 56058f7 commit 0a9f5ec
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions dialog.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,21 @@ 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 {
frame = focused.FrameRect()
} 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)
}
Expand Down

0 comments on commit 0a9f5ec

Please sign in to comment.