summaryrefslogtreecommitdiffstats
path: root/library/button.tcl
diff options
context:
space:
mode:
authorericm <ericm>2000-05-13 00:39:06 (GMT)
committerericm <ericm>2000-05-13 00:39:06 (GMT)
commitbfa082e9202bf219a84a4bb0d997d6cf1f834516 (patch)
treeb61f779971a9663ee07b65009e60aa206dd22e32 /library/button.tcl
parent32c00bd4e54bd4254300852356a6fff59d388d45 (diff)
downloadtk-bfa082e9202bf219a84a4bb0d997d6cf1f834516.zip
tk-bfa082e9202bf219a84a4bb0d997d6cf1f834516.tar.gz
tk-bfa082e9202bf219a84a4bb0d997d6cf1f834516.tar.bz2
* unix/tkUnixButton.c (TkpDisplayButton, TkpComputeButtonGeometry):
* mac/tkMacButton.c (TkpDisplayButton, TkpComputeButtonGeometry): * win/tkWinButton.c (TkpDisplayButton, TkpComputeButtonGeometry): Added code for drawing compound buttons. * tests/button.test: Added configuration tests for -repeatdelay, -repeatinterval, -compound. * library/button.tcl: Added support for -repeatedelay, -repeatinterval options. * generic/tkOldConfig.c: Changed handling of link relief so that proper error messages are used. * generic/tkButton.h: Added -compound, -repeatdelay, -repeatinterval options. * generic/tkButton.c: Added event watchers for enter/leave events, for link relief support. * generic/tk3d.c: Changed handling of link relief so that proper error messages are used. * generic/tk.h: Changed values of TK_OPTION_LINK_OK/TK_CONFIG_LINK_OK for link relief support.
Diffstat (limited to 'library/button.tcl')
-rw-r--r--library/button.tcl73
1 files changed, 69 insertions, 4 deletions
diff --git a/library/button.tcl b/library/button.tcl
index 8feeba8..0184648 100644
--- a/library/button.tcl
+++ b/library/button.tcl
@@ -4,7 +4,7 @@
# checkbutton, and radiobutton widgets and provides procedures
# that help in implementing those bindings.
#
-# RCS: @(#) $Id: button.tcl,v 1.6 1999/09/02 17:02:52 hobbs Exp $
+# RCS: @(#) $Id: button.tcl,v 1.7 2000/05/13 00:39:08 ericm Exp $
#
# Copyright (c) 1992-1994 The Regents of the University of California.
# Copyright (c) 1994-1996 Sun Microsystems, Inc.
@@ -203,6 +203,14 @@ proc tkButtonDown w {
if {[string compare [$w cget -state] "disabled"]} {
set tkPriv(buttonWindow) $w
$w configure -relief sunken -state active
+
+ # If this button has a repeatdelay set up, get it going with an after
+ after cancel $tkPriv(afterId)
+ set delay [$w cget -repeatdelay]
+ set tkPriv(repeated) 0
+ if {$delay > 0} {
+ set tkPriv(afterId) [after $delay [list tkButtonAutoInvoke $w]]
+ }
}
}
@@ -240,7 +248,12 @@ proc tkButtonUp w {
if {[string equal $tkPriv(window) $w]
&& [string compare [$w cget -state] "disabled"]} {
$w configure -state normal
- uplevel #0 [list $w invoke]
+
+ # Only invoke the command if it wasn't already invoked by the
+ # auto-repeater functionality
+ if { $tkPriv(repeated) == 0 } {
+ uplevel #0 [list $w invoke]
+ }
}
}
}
@@ -308,6 +321,14 @@ proc tkButtonDown w {
if {[string compare [$w cget -state] "disabled"]} {
set tkPriv(buttonWindow) $w
$w configure -relief sunken
+
+ # If this button has a repeatdelay set up, get it going with an after
+ after cancel $tkPriv(afterId)
+ set delay [$w cget -repeatdelay]
+ set tkPriv(repeated) 0
+ if {$delay > 0} {
+ set tkPriv(afterId) [after $delay [list tkButtonAutoInvoke $w]]
+ }
}
}
@@ -324,9 +345,15 @@ proc tkButtonUp w {
if {[string equal $w $tkPriv(buttonWindow)]} {
set tkPriv(buttonWindow) ""
$w configure -relief $tkPriv(relief)
+ after cancel $tkPriv(afterId)
if {[string equal $w $tkPriv(window)] \
&& [string compare [$w cget -state] "disabled"]} {
- uplevel #0 [list $w invoke]
+
+ # Only invoke the command if it wasn't already invoked by the
+ # auto-repeater functionality
+ if { $tkPriv(repeated) == 0 } {
+ uplevel #0 [list $w invoke]
+ }
}
}
}
@@ -389,6 +416,14 @@ proc tkButtonDown w {
if {[string compare [$w cget -state] "disabled"]} {
set tkPriv(buttonWindow) $w
$w configure -state active
+
+ # If this button has a repeatdelay set up, get it going with an after
+ after cancel $tkPriv(afterId)
+ set delay [$w cget -repeatdelay]
+ set tkPriv(repeated) 0
+ if {$delay > 0} {
+ set tkPriv(afterId) [after $delay [list tkButtonAutoInvoke $w]]
+ }
}
}
@@ -407,7 +442,11 @@ proc tkButtonUp w {
set tkPriv(buttonWindow) ""
if {[string equal $w $tkPriv(window)]
&& [string compare [$w cget -state] "disabled"]} {
- uplevel #0 [list $w invoke]
+ # Only invoke the command if it wasn't already invoked by the
+ # auto-repeater functionality
+ if { $tkPriv(repeated) == 0 } {
+ uplevel #0 [list $w invoke]
+ }
}
}
}
@@ -437,6 +476,32 @@ proc tkButtonInvoke w {
}
}
+# tkButtonAutoInvoke --
+#
+# Invoke an auto-repeating button, and set it up to continue to repeat.
+#
+# Arguments:
+# w button to invoke.
+#
+# Results:
+# None.
+#
+# Side effects:
+# May create an after event to call tkButtonAutoInvoke.
+
+proc tkButtonAutoInvoke {w} {
+ global tkPriv
+ after cancel $tkPriv(afterId)
+ set delay [$w cget -repeatinterval]
+ if { [string equal $tkPriv(window) $w] } {
+ incr tkPriv(repeated)
+ uplevel #0 [list $w invoke]
+ }
+ if {$delay > 0} {
+ set tkPriv(afterId) [after $delay [list tkButtonAutoInvoke $w]]
+ }
+}
+
# tkCheckRadioInvoke --
# The procedure below is invoked when the mouse button is pressed in
# a checkbutton or radiobutton widget, or when the widget is invoked