From c0a5330968e77479f410ea8d5cc75e5d8f0c5a1b Mon Sep 17 00:00:00 2001 From: Evan <17254809+bigun27@users.noreply.github.com> Date: Tue, 9 Jul 2024 23:47:11 -0400 Subject: [PATCH] Add AlwaysOnTop() --- msg_windows.go | 5 +++++ zenity.go | 8 ++++++++ 2 files changed, 13 insertions(+) diff --git a/msg_windows.go b/msg_windows.go index 15b6fa3..8863a3a 100644 --- a/msg_windows.go +++ b/msg_windows.go @@ -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) diff --git a/zenity.go b/zenity.go index 3acc873..32a8660 100644 --- a/zenity.go +++ b/zenity.go @@ -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) {