Skip to content

Commit 76f1594

Browse files
angavrilovpaulusmack
authored andcommitted
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 <[email protected]> Signed-off-by: Paul Mackerras <[email protected]>
1 parent e3e901b commit 76f1594

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

gitk

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1746,6 +1746,8 @@ proc show_error {w top msg} {
17461746
pack $w.ok -side bottom -fill x
17471747
bind $top <Visibility> "grab $top; focus $top"
17481748
bind $top <Key-Return> "destroy $top"
1749+
bind $top <Key-space> "destroy $top"
1750+
bind $top <Key-Escape> "destroy $top"
17491751
tkwait window $top
17501752
}
17511753

@@ -1769,6 +1771,9 @@ proc confirm_popup msg {
17691771
button $w.cancel -text [mc Cancel] -command "destroy $w"
17701772
pack $w.cancel -side right -fill x
17711773
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"
17721777
tkwait window $w
17731778
return $confirm_ok
17741779
}
@@ -2611,6 +2616,7 @@ proc keys {} {
26112616
-justify left -bg white -border 2 -relief groove
26122617
pack $w.m -side top -fill both -padx 2 -pady 2
26132618
button $w.ok -text [mc "Close"] -command "destroy $w" -default active
2619+
bind $w <Key-Escape> [list destroy $w]
26142620
pack $w.ok -side bottom
26152621
bind $w <Visibility> "focus $w.ok"
26162622
bind $w <Key-Escape> "destroy $w"
@@ -3533,6 +3539,7 @@ proc vieweditor {top n title} {
35333539
frame $top.buts
35343540
button $top.buts.ok -text [mc "OK"] -command [list newviewok $top $n]
35353541
button $top.buts.can -text [mc "Cancel"] -command [list destroy $top]
3542+
bind $top <Escape> [list destroy $top]
35363543
grid $top.buts.ok $top.buts.can
35373544
grid columnconfigure $top.buts 0 -weight 1 -uniform a
35383545
grid columnconfigure $top.buts 1 -weight 1 -uniform a
@@ -7793,6 +7800,8 @@ proc mkpatch {} {
77937800
frame $top.buts
77947801
button $top.buts.gen -text [mc "Generate"] -command mkpatchgo
77957802
button $top.buts.can -text [mc "Cancel"] -command mkpatchcan
7803+
bind $top <Key-Return> mkpatchgo
7804+
bind $top <Key-Escape> mkpatchcan
77967805
grid $top.buts.gen $top.buts.can
77977806
grid columnconfigure $top.buts 0 -weight 1 -uniform a
77987807
grid columnconfigure $top.buts 1 -weight 1 -uniform a
@@ -7864,6 +7873,8 @@ proc mktag {} {
78647873
frame $top.buts
78657874
button $top.buts.gen -text [mc "Create"] -command mktaggo
78667875
button $top.buts.can -text [mc "Cancel"] -command mktagcan
7876+
bind $top <Key-Return> mktaggo
7877+
bind $top <Key-Escape> mktagcan
78677878
grid $top.buts.gen $top.buts.can
78687879
grid columnconfigure $top.buts 0 -weight 1 -uniform a
78697880
grid columnconfigure $top.buts 1 -weight 1 -uniform a
@@ -7967,6 +7978,8 @@ proc writecommit {} {
79677978
frame $top.buts
79687979
button $top.buts.gen -text [mc "Write"] -command wrcomgo
79697980
button $top.buts.can -text [mc "Cancel"] -command wrcomcan
7981+
bind $top <Key-Return> wrcomgo
7982+
bind $top <Key-Escape> wrcomcan
79707983
grid $top.buts.gen $top.buts.can
79717984
grid columnconfigure $top.buts 0 -weight 1 -uniform a
79727985
grid columnconfigure $top.buts 1 -weight 1 -uniform a
@@ -8014,6 +8027,8 @@ proc mkbranch {} {
80148027
frame $top.buts
80158028
button $top.buts.go -text [mc "Create"] -command [list mkbrgo $top]
80168029
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}"
80178032
grid $top.buts.go $top.buts.can
80188033
grid columnconfigure $top.buts 0 -weight 1 -uniform a
80198034
grid columnconfigure $top.buts 1 -weight 1 -uniform a
@@ -8138,6 +8153,7 @@ proc resethead {} {
81388153
button $w.ok -text [mc OK] -command "set confirm_ok 1; destroy $w"
81398154
pack $w.ok -side left -fill x -padx 20 -pady 20
81408155
button $w.cancel -text [mc Cancel] -command "destroy $w"
8156+
bind $w <Key-Escape> [list destroy $w]
81418157
pack $w.cancel -side right -fill x -padx 20 -pady 20
81428158
bind $w <Visibility> "grab $w; focus $w"
81438159
tkwait window $w
@@ -8315,6 +8331,7 @@ proc showrefs {} {
83158331
pack $top.f.l -side left
83168332
grid $top.f - -sticky ew -pady 2
83178333
button $top.close -command [list destroy $top] -text [mc "Close"]
8334+
bind $top <Key-Escape> [list destroy $top]
83188335
grid $top.close -
83198336
grid columnconfigure $top 0 -weight 1
83208337
grid rowconfigure $top 0 -weight 1
@@ -9666,6 +9683,8 @@ proc choosefont {font which} {
96669683
frame $top.buts
96679684
button $top.buts.ok -text [mc "OK"] -command fontok -default active
96689685
button $top.buts.can -text [mc "Cancel"] -command fontcan -default normal
9686+
bind $top <Key-Return> fontok
9687+
bind $top <Key-Escape> fontcan
96699688
grid $top.buts.ok $top.buts.can
96709689
grid columnconfigure $top.buts 0 -weight 1 -uniform a
96719690
grid columnconfigure $top.buts 1 -weight 1 -uniform a
@@ -9845,6 +9864,8 @@ proc doprefs {} {
98459864
frame $top.buts
98469865
button $top.buts.ok -text [mc "OK"] -command prefsok -default active
98479866
button $top.buts.can -text [mc "Cancel"] -command prefscan -default normal
9867+
bind $top <Key-Return> prefsok
9868+
bind $top <Key-Escape> prefscan
98489869
grid $top.buts.ok $top.buts.can
98499870
grid columnconfigure $top.buts 0 -weight 1 -uniform a
98509871
grid columnconfigure $top.buts 1 -weight 1 -uniform a

0 commit comments

Comments
 (0)