summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpatthoyts <patthoyts@users.sourceforge.net>2011-03-19 02:02:49 (GMT)
committerpatthoyts <patthoyts@users.sourceforge.net>2011-03-19 02:02:49 (GMT)
commit10e66075da50c83da5d496b5624a8648ef9c3a43 (patch)
tree2f99ee8dbd95298ebdb8e68780c148bfd3151a1e
parent9877bff21b10ed751ef2d404fbd7b0a630714f43 (diff)
parent2d6d54e8eddb42bb1f0ea1d7e8f2a36f07b93cc8 (diff)
downloadtk-10e66075da50c83da5d496b5624a8648ef9c3a43.zip
tk-10e66075da50c83da5d496b5624a8648ef9c3a43.tar.gz
tk-10e66075da50c83da5d496b5624a8648ef9c3a43.tar.bz2
[Bug 3223850] - button remains stuck when disabled as depressed on XP
If a button is disabled while the state is pressed, then the release event handler did not remove the pressed state. Modified the handler to always remove the pressed state while only calling invoke if !disabled. Reported-by: Thomas MENEZ <thomasmenez@users.sourceforge.net> Signed-off-by: Pat Thoyts <patthoyts@users.sourceforge.net>
-rw-r--r--library/ttk/button.tcl2
-rw-r--r--tests/ttk/ttk.test17
2 files changed, 18 insertions, 1 deletions
diff --git a/library/ttk/button.tcl b/library/ttk/button.tcl
index 3baefe2..22032e4 100644
--- a/library/ttk/button.tcl
+++ b/library/ttk/button.tcl
@@ -28,7 +28,7 @@ bind TButton <<Invoke>> { ttk::button::activate %W }
bind TButton <ButtonPress-1> \
{ %W instate !disabled { ttk::clickToFocus %W; %W state pressed } }
bind TButton <ButtonRelease-1> \
- { %W instate {pressed !disabled} { %W state !pressed; %W invoke } }
+ { %W instate pressed { %W state !pressed; %W instate !disabled { %W invoke } } }
bind TButton <Button1-Leave> \
{ %W state !pressed }
bind TButton <Button1-Enter> \
diff --git a/tests/ttk/ttk.test b/tests/ttk/ttk.test
index 9732f46..ddfaf84 100644
--- a/tests/ttk/ttk.test
+++ b/tests/ttk/ttk.test
@@ -197,6 +197,23 @@ test ttk-2.7 "instate scripts, true" -body {
set x
} -result 1
+test ttk-2.8 "bug 3223850: button state disabled during click" -setup {
+ destroy .b
+ set ttk28 {}
+ pack [ttk::button .b -command {set ::ttk28 failed}]
+} -body {
+ bind .b <ButtonPress-1> {after 0 {.b configure -state disabled}}
+ after 1 {event generate .b <ButtonPress-1>}
+ after 20 {event generate .b <ButtonRelease-1>}
+ set aid [after 100 {set ::ttk28 [.b instate {disabled !pressed}]}]
+ vwait ::ttk28
+ after cancel $aid
+ set ttk28
+} -cleanup {
+ destroy .b
+ unset -nocomplain ttk28 aid
+} -result 1
+
# misc. error detection
test ttk-3.0 "Bad option" -body {
ttk::button .bad -badoption foo