gitk: Add Return and Escape bindings to dialogs
It is often more convenient to dismiss or accept a dialog using the keyboard, than by clicking buttons on the screen. This commit adds key binding to make it possible with gitk's dialogs. Signed-off-by: Alexander Gavrilov <angavrilov@gmail.com> Signed-off-by: Paul Mackerras <paulus@samba.org>
Alexander Gavrilov committed
Nov 2, 2008 at 21:59 UTC
76f15947af78f526925810487f69fed35f6a7daf
1 file changed
+21
gitk
+21
@@ -1746,6 +1746,8 @@ proc show_error {w top msg} {
1746
pack $w.ok -side bottom -fill x
1747
bind $top <Visibility> "grab $top; focus $top"
1748
bind $top <Key-Return> "destroy $top"
1749
+ bind $top <Key-space> "destroy $top"
1750
+ bind $top <Key-Escape> "destroy $top"
1751
tkwait window $top
1752
}
1753
@@ -1769,6 +1771,9 @@ proc confirm_popup msg {
1771
button $w.cancel -text [mc Cancel] -command "destroy $w"
1772
pack $w.cancel -side right -fill x
1773
bind $w <Visibility> "grab $w; focus $w"
1774
+ bind $w <Key-Return> "set confirm_ok 1; destroy $w"
1775
+ bind $w <Key-space> "set confirm_ok 1; destroy $w"
1776
+ bind $w <Key-Escape> "destroy $w"
1777
tkwait window $w
1778
return $confirm_ok
1779
}
@@ -2611,6 +2616,7 @@ proc keys {} {
2616
-justify left -bg white -border 2 -relief groove
2617
pack $w.m -side top -fill both -padx 2 -pady 2
2618
button $w.ok -text [mc "Close"] -command "destroy $w" -default active
2619
+ bind $w <Key-Escape> [list destroy $w]
2620
pack $w.ok -side bottom
2621
bind $w <Visibility> "focus $w.ok"
2622
bind $w <Key-Escape> "destroy $w"
@@ -3533,6 +3539,7 @@ proc vieweditor {top n title} {
3539
frame $top.buts
3540
button $top.buts.ok -text [mc "OK"] -command [list newviewok $top $n]
3541
button $top.buts.can -text [mc "Cancel"] -command [list destroy $top]
3542
+ bind $top <Escape> [list destroy $top]
3543
grid $top.buts.ok $top.buts.can
3544
grid columnconfigure $top.buts 0 -weight 1 -uniform a
3545
grid columnconfigure $top.buts 1 -weight 1 -uniform a
@@ -7793,6 +7800,8 @@ proc mkpatch {} {
7800
frame $top.buts
7801
button $top.buts.gen -text [mc "Generate"] -command mkpatchgo
7802
button $top.buts.can -text [mc "Cancel"] -command mkpatchcan
7803
+ bind $top <Key-Return> mkpatchgo
7804
+ bind $top <Key-Escape> mkpatchcan
7805
grid $top.buts.gen $top.buts.can
7806
grid columnconfigure $top.buts 0 -weight 1 -uniform a
7807
grid columnconfigure $top.buts 1 -weight 1 -uniform a
@@ -7864,6 +7873,8 @@ proc mktag {} {
7873
frame $top.buts
7874
button $top.buts.gen -text [mc "Create"] -command mktaggo
7875
button $top.buts.can -text [mc "Cancel"] -command mktagcan
7876
+ bind $top <Key-Return> mktaggo
7877
+ bind $top <Key-Escape> mktagcan
7878
grid $top.buts.gen $top.buts.can
7879
grid columnconfigure $top.buts 0 -weight 1 -uniform a
7880
grid columnconfigure $top.buts 1 -weight 1 -uniform a
@@ -7967,6 +7978,8 @@ proc writecommit {} {
7978
frame $top.buts
7979
button $top.buts.gen -text [mc "Write"] -command wrcomgo
7980
button $top.buts.can -text [mc "Cancel"] -command wrcomcan
7981
+ bind $top <Key-Return> wrcomgo
7982
+ bind $top <Key-Escape> wrcomcan
7983
grid $top.buts.gen $top.buts.can
7984
grid columnconfigure $top.buts 0 -weight 1 -uniform a
7985
grid columnconfigure $top.buts 1 -weight 1 -uniform a
@@ -8014,6 +8027,8 @@ proc mkbranch {} {
8027
frame $top.buts
8028
button $top.buts.go -text [mc "Create"] -command [list mkbrgo $top]
8029
button $top.buts.can -text [mc "Cancel"] -command "catch {destroy $top}"
8030
+ bind $top <Key-Return> [list mkbrgo $top]
8031
+ bind $top <Key-Escape> "catch {destroy $top}"
8032
grid $top.buts.go $top.buts.can
8033
grid columnconfigure $top.buts 0 -weight 1 -uniform a
8034
grid columnconfigure $top.buts 1 -weight 1 -uniform a
@@ -8138,6 +8153,7 @@ proc resethead {} {
8153
button $w.ok -text [mc OK] -command "set confirm_ok 1; destroy $w"
8154
pack $w.ok -side left -fill x -padx 20 -pady 20
8155
button $w.cancel -text [mc Cancel] -command "destroy $w"
8156
+ bind $w <Key-Escape> [list destroy $w]
8157
pack $w.cancel -side right -fill x -padx 20 -pady 20
8158
bind $w <Visibility> "grab $w; focus $w"
8159
tkwait window $w
@@ -8315,6 +8331,7 @@ proc showrefs {} {
8331
pack $top.f.l -side left
8332
grid $top.f - -sticky ew -pady 2
8333
button $top.close -command [list destroy $top] -text [mc "Close"]
8334
+ bind $top <Key-Escape> [list destroy $top]
8335
grid $top.close -
8336
grid columnconfigure $top 0 -weight 1
8337
grid rowconfigure $top 0 -weight 1
@@ -9666,6 +9683,8 @@ proc choosefont {font which} {
9683
frame $top.buts
9684
button $top.buts.ok -text [mc "OK"] -command fontok -default active
9685
button $top.buts.can -text [mc "Cancel"] -command fontcan -default normal
9686
+ bind $top <Key-Return> fontok
9687
+ bind $top <Key-Escape> fontcan
9688
grid $top.buts.ok $top.buts.can
9689
grid columnconfigure $top.buts 0 -weight 1 -uniform a
9690
grid columnconfigure $top.buts 1 -weight 1 -uniform a
@@ -9845,6 +9864,8 @@ proc doprefs {} {
9864
frame $top.buts
9865
button $top.buts.ok -text [mc "OK"] -command prefsok -default active
9866
button $top.buts.can -text [mc "Cancel"] -command prefscan -default normal
9867
+ bind $top <Key-Return> prefsok
9868
+ bind $top <Key-Escape> prefscan
9869
grid $top.buts.ok $top.buts.can
9870
grid columnconfigure $top.buts 0 -weight 1 -uniform a
9871
grid columnconfigure $top.buts 1 -weight 1 -uniform a