summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2016-03-14 14:09:03 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2016-03-14 14:09:03 (GMT)
commit63504284a60a6ae199422ecb41637700339cd333 (patch)
treea958d9b7481d9098b9553460b700b2e2ca107ceb
parent6669e94c070680392a0e8c77203e45084d9c09d0 (diff)
downloadtk-63504284a60a6ae199422ecb41637700339cd333.zip
tk-63504284a60a6ae199422ecb41637700339cd333.tar.gz
tk-63504284a60a6ae199422ecb41637700339cd333.tar.bz2
Suggested fix for [38dc27bd1d0ecd68]: Tk does not support <Button-6> nor <Button-7> events. With test-cases and doc change.
-rw-r--r--doc/bind.n2
-rw-r--r--generic/tkBind.c2
-rw-r--r--tests/bind.test60
3 files changed, 60 insertions, 4 deletions
diff --git a/doc/bind.n b/doc/bind.n
index ab02396..becc08b 100644
--- a/doc/bind.n
+++ b/doc/bind.n
@@ -351,7 +351,7 @@ position in the stacking order.
.PP
The last part of a long event specification is \fIdetail\fR. In the
case of a \fBButtonPress\fR or \fBButtonRelease\fR event, it is the
-number of a button (1\-5). If a button number is given, then only an
+number of a button (1\-9). If a button number is given, then only an
event on that particular button will match; if no button number is
given, then an event on any button will match. Note: giving a
specific button number is different than specifying a button modifier;
diff --git a/generic/tkBind.c b/generic/tkBind.c
index 9cd3b7b..cb516e8 100644
--- a/generic/tkBind.c
+++ b/generic/tkBind.c
@@ -3937,7 +3937,7 @@ ParseEventDescription(
p = GetField(p, field, FIELD_SIZE);
}
if (*field != '\0') {
- if ((*field >= '1') && (*field <= '5') && (field[1] == '\0')) {
+ if ((*field >= '1') && (*field <= '9') && (field[1] == '\0')) {
if (eventFlags == 0) {
patPtr->eventType = ButtonPress;
eventMask = ButtonPressMask;
diff --git a/tests/bind.test b/tests/bind.test
index f38f03c..1b1107a 100644
--- a/tests/bind.test
+++ b/tests/bind.test
@@ -5757,8 +5757,8 @@ test bind-27.1 {button names} -body {
bind .t <Expose-1> foo
} -returnCodes error -result {specified button "1" for non-button event}
test bind-27.2 {button names} -body {
- bind .t <Button-6> foo
-} -returnCodes error -result {specified keysym "6" for non-key event}
+ bind .t <Button-@> foo
+} -returnCodes error -result {specified keysym "@" for non-key event}
test bind-27.3 {button names} -setup {
frame .t.f -class Test -width 150 -height 100
pack .t.f
@@ -5829,6 +5829,62 @@ test bind-27.7 {button names} -setup {
} -cleanup {
destroy .t.f
} -result {<Button-5> {button 5}}
+test bind-27.8 {button names} -setup {
+ frame .t.f -class Test -width 150 -height 100
+ pack .t.f
+ focus -force .t.f
+ update
+} -body {
+ bind .t.f <Button-6> {lappend x "button 6"}
+ set x [bind .t.f]
+ event generate .t.f <Button-6>
+ event generate .t.f <ButtonRelease-6>
+ set x
+} -cleanup {
+ destroy .t.f
+} -result {<Button-6> {button 6}}
+test bind-27.9 {button names} -setup {
+ frame .t.f -class Test -width 150 -height 100
+ pack .t.f
+ focus -force .t.f
+ update
+} -body {
+ bind .t.f <Button-7> {lappend x "button 7"}
+ set x [bind .t.f]
+ event generate .t.f <Button-7>
+ event generate .t.f <ButtonRelease-7>
+ set x
+} -cleanup {
+ destroy .t.f
+} -result {<Button-7> {button 7}}
+test bind-27.10 {button names} -setup {
+ frame .t.f -class Test -width 150 -height 100
+ pack .t.f
+ focus -force .t.f
+ update
+} -body {
+ bind .t.f <Button-8> {lappend x "button 8"}
+ set x [bind .t.f]
+ event generate .t.f <Button-8>
+ event generate .t.f <ButtonRelease-8>
+ set x
+} -cleanup {
+ destroy .t.f
+} -result {<Button-8> {button 8}}
+test bind-27.11 {button names} -setup {
+ frame .t.f -class Test -width 150 -height 100
+ pack .t.f
+ focus -force .t.f
+ update
+} -body {
+ bind .t.f <Button-9> {lappend x "button 9"}
+ set x [bind .t.f]
+ event generate .t.f <Button-9>
+ event generate .t.f <ButtonRelease-9>
+ set x
+} -cleanup {
+ destroy .t.f
+} -result {<Button-9> {button 9}}
test bind-28.1 {keysym names} -body {
bind .t <Expose-a> foo