summaryrefslogtreecommitdiffstats
path: root/library/dialog.tcl
diff options
context:
space:
mode:
Diffstat (limited to 'library/dialog.tcl')
-rw-r--r--library/dialog.tcl50
1 files changed, 16 insertions, 34 deletions
diff --git a/library/dialog.tcl b/library/dialog.tcl
index 04acb3b..abe142b 100644
--- a/library/dialog.tcl
+++ b/library/dialog.tcl
@@ -37,7 +37,6 @@ proc ::tk_dialog {w title text bitmap default args} {
return -code error "default button index greater than number of\
buttons specified for tk_dialog"
}
- # Never call if -strict option is omitted in previous test !
} elseif {"" eq $default} {
set default -1
} else {
@@ -45,7 +44,7 @@ proc ::tk_dialog {w title text bitmap default args} {
}
set windowingsystem [tk windowingsystem]
- if {$tcl_platform(platform) eq "macintosh" || $windowingsystem eq "aqua"} {
+ if {$windowingsystem eq "aqua"} {
option add *Dialog*background systemDialogBackgroundActive widgetDefault
option add *Dialog*Button.highlightBackground \
systemDialogBackgroundActive widgetDefault
@@ -71,7 +70,7 @@ proc ::tk_dialog {w title text bitmap default args} {
wm transient $w [winfo toplevel [winfo parent $w]]
}
- if {$tcl_platform(platform) eq "macintosh" || $windowingsystem eq "aqua"} {
+ if {$windowingsystem eq "aqua"} {
::tk::unsupported::MacWindowStyle style $w moveableModal {}
} elseif {$windowingsystem eq "x11"} {
wm attributes $w -type dialog
@@ -85,23 +84,19 @@ proc ::tk_dialog {w title text bitmap default args} {
}
pack $w.bot -side bottom -fill both
pack $w.top -side top -fill both -expand 1
+ grid anchor $w.bot center
# 2. Fill the top part with bitmap and message (use the option
# database for -wraplength and -font so that they can be
# overridden by the caller).
option add *Dialog.msg.wrapLength 3i widgetDefault
- if {$tcl_platform(platform) eq "macintosh" || $windowingsystem eq "aqua"} {
- option add *Dialog.msg.font system widgetDefault
- } else {
- option add *Dialog.msg.font {Times 12} widgetDefault
- }
+ option add *Dialog.msg.font TkCaptionFont widgetDefault
label $w.msg -justify left -text $text
pack $w.msg -in $w.top -side right -expand 1 -fill both -padx 3m -pady 3m
if {$bitmap ne ""} {
- if {($tcl_platform(platform) eq "macintosh"
- || $windowingsystem eq "aqua") && ($bitmap eq "error")} {
+ if {$windowingsystem eq "aqua" && $bitmap eq "error"} {
set bitmap "stop"
}
label $w.bitmap -bitmap $bitmap
@@ -122,7 +117,7 @@ proc ::tk_dialog {w title text bitmap default args} {
-padx 10 -pady 4
grid columnconfigure $w.bot $i
# We boost the size of some Mac buttons for l&f
- if {$tcl_platform(platform) eq "macintosh" || $windowingsystem eq "aqua"} {
+ if {$windowingsystem eq "aqua"} {
set tmp [string tolower $but]
if {$tmp eq "ok" || $tmp eq "cancel"} {
grid columnconfigure $w.bot $i -minsize 90
@@ -134,15 +129,14 @@ proc ::tk_dialog {w title text bitmap default args} {
# 4. Create a binding for <Return> on the dialog if there is a
# default button.
+ # Convention also dictates that if the keyboard focus moves among the
+ # the buttons that the <Return> binding affects the button with the focus.
if {$default >= 0} {
- bind $w <Return> "
- [list $w.button$default] configure -state active -relief sunken
- update idletasks
- after 100
- set ::tk::Priv(button) $default
- "
+ bind $w <Return> [list $w.button$default invoke]
}
+ bind $w <<PrevWindow>> [list bind $w <Return> {[tk_focusPrev %W] invoke}]
+ bind $w <Tab> [list bind $w <Return> {[tk_focusNext %W] invoke}]
# 5. Create a <Destroy> binding for the window that sets the
# button variable to -1; this is needed in case something happens
@@ -177,17 +171,12 @@ proc ::tk_dialog {w title text bitmap default args} {
# 7. Set a grab and claim the focus too.
- set oldFocus [focus]
- set oldGrab [grab current $w]
- if {$oldGrab ne ""} {
- set grabStatus [grab status $oldGrab]
- }
- grab $w
if {$default >= 0} {
- focus $w.button$default
+ set focus $w.button$default
} else {
- focus $w
+ set focus $w
}
+ tk::SetFocusGrab $w $focus
# 8. Wait for the user to respond, then restore the focus and
# return the index of the selected button. Restore the focus
@@ -196,21 +185,14 @@ proc ::tk_dialog {w title text bitmap default args} {
# restore any grab that was in effect.
vwait ::tk::Priv(button)
- catch {focus $oldFocus}
+
catch {
# It's possible that the window has already been destroyed,
# hence this "catch". Delete the Destroy handler so that
# Priv(button) doesn't get reset by it.
bind $w <Destroy> {}
- destroy $w
- }
- if {$oldGrab ne ""} {
- if {$grabStatus ne "global"} {
- grab $oldGrab
- } else {
- grab -global $oldGrab
- }
}
+ tk::RestoreFocusGrab $w $focus
return $Priv(button)
}