Add AlwaysOnTop()

This commit is contained in:
Evan 2024-07-09 23:47:11 -04:00
parent 3c4211a27f
commit c136d7c048
2 changed files with 13 additions and 0 deletions

View file

@ -4,6 +4,7 @@ import (
"context"
"github.com/ncruces/zenity/internal/win"
"golang.org/x/sys/windows"
)
func message(kind messageKind, text string, opts options) error {
@ -52,6 +53,10 @@ func message(kind messageKind, text string, opts options) error {
}
}
if opts.alwaysOnTop {
flags |= windows.MB_SYSTEMMODAL
}
owner, _ := opts.attach.(win.HWND)
defer setup(owner)()
unhook, err := hookMessageDialog(opts)

View file

@ -39,6 +39,7 @@ func IsAvailable() bool {
type options struct {
// General options
title *string
alwaysOnTop bool
width uint
height uint
okLabel *string
@ -115,6 +116,13 @@ func Title(title string) Option {
return funcOption(func(o *options) { o.title = &title })
}
// AlwaysOnTop returns an Option to set the dialog to be always on top (Windows only)..
func AlwaysOnTop(alwaysOnTop bool) Option {
return funcOption(func(o *options) {
o.alwaysOnTop = alwaysOnTop
})
}
// Width returns an Option to set the dialog width (Unix only).
func Width(width uint) Option {
return funcOption(func(o *options) {