Add AlwaysOnTop()
This commit is contained in:
parent
c3f7e410c2
commit
c0a5330968
2 changed files with 13 additions and 0 deletions
|
@ -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)
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue