From 1e7c9553a21edc3e757745f1d5c4e887bbcde1df Mon Sep 17 00:00:00 2001 From: Siep Kroonenberg Date: Fri, 11 Oct 2019 11:45:12 +0000 Subject: Better handling of titlebar Close button git-svn-id: svn://tug.org/texlive/trunk@52337 c570f23f-e606-0410-a88d-b1316a301751 --- Master/tlpkg/tltcl/tltcl.tcl | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'Master/tlpkg/tltcl/tltcl.tcl') diff --git a/Master/tlpkg/tltcl/tltcl.tcl b/Master/tlpkg/tltcl/tltcl.tcl index edb20eb5f02..b0b8d1c19d5 100644 --- a/Master/tlpkg/tltcl/tltcl.tcl +++ b/Master/tlpkg/tltcl/tltcl.tcl @@ -451,6 +451,10 @@ set ::env(NOPERLDOC) 1 # for example code, look at dialog.tcl, part of Tk itself +# In most cases, it is not necessary to explicitly define a handler for +# the WM_DELETE_WINDOW protocol. But if the cancel- or abort button would do +# anything special, then the close icon should not bypass this. + # widget classes which can be enabled and disabled. # The text widget class is not included here. @@ -468,7 +472,6 @@ proc create_dlg {wnd {p .}} { wm withdraw $wnd if [winfo viewable $p] {wm transient $wnd $p} if $::plain_unix {wm attributes $wnd -type dialog} - wm protocol $wnd WM_DELETE_WINDOW {destroy $wnd} } # Place a dialog centered wrt its parent. @@ -515,6 +518,15 @@ proc end_dlg {ans wnd} { destroy $wnd } ; # end_dlg +# a possibly useful callback for WM_DELETE_WINDOW +proc cancel_or_destroy {ctrl topl} { + if [winfo exists $ctrl] { + $ctrl invoke + } elseif [winfo exists $topl] { + destroy $topl + } +} + ##### directories ##### # slash flipping @@ -576,6 +588,8 @@ if {$::tcl_platform(platform) eq "unix"} { ppack [ttk::button .browser.cancel -text [__ "Cancel"]] \ -in .browser.fr1 -side right bind .browser {.browser.cancel invoke} + wm protocol .browser WM_DELETE_WINDOW \ + {cancel_or_destroy .browser.cancel .browser} .browser.ok configure -command { set ::dialog_ans [.browser.tree focus] destroy .browser -- cgit v1.2.3