git-gui: Fix focus transition in the blame viewer.
Now that the blame viewer has a search panel, it should be taken into account by the focus transition code. Otherwise showing a commit tip (by accidentally moving the mouse to the text frame) causes the focus to transfer away from the search field. Signed-off-by: Alexander Gavrilov <angavrilov@gmail.com> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Alexander Gavrilov committed
Nov 9, 2008 at 18:36 UTC
b28ebab294fb13f1bb5cd36ab9774a6dcf50a004
2 files changed
+23
-7
lib/blame.tcl
+12
-4
@@ -321,7 +321,7 @@ constructor new {i_commit i_path i_jump} {
321
tk_popup $w.ctxm %X %Y
322
"
323
bind $i <Shift-Tab> "[list focus $w_cviewer];break"
324
- bind $i <Tab> "[list focus $w_cviewer];break"
324
+ bind $i <Tab> "[cb _focus_search $w_cviewer];break"
325
}
326
327
foreach i [concat $w_columns $w_cviewer] {
@@ -337,10 +337,10 @@ constructor new {i_commit i_path i_jump} {
337
bind $i <Control-Key-f> {catch {%W yview scroll 1 pages};break}
338
}
339
340
- bind $w_cviewer <Shift-Tab> "[list focus $w_file];break"
340
+ bind $w_cviewer <Shift-Tab> "[cb _focus_search $w_file];break"
341
bind $w_cviewer <Tab> "[list focus $w_file];break"
342
- bind $w_cviewer <Button-1> [list focus $w_cviewer]
343
- bind $w_file <Visibility> [list focus $w_file]
342
+ bind $w_cviewer <Button-1> [list focus $w_cviewer]
343
+ bind $w_file <Visibility> [cb _focus_search $w_file]
344
bind $top <F7> [list searchbar::show $finder]
345
bind $top <Escape> [list searchbar::hide $finder]
346
bind $top <F3> [list searchbar::find_next $finder]
@@ -382,6 +382,14 @@ constructor new {i_commit i_path i_jump} {
382
_load $this $i_jump
383
}
384
385
+method _focus_search {win} {
386
+ if {[searchbar::visible $finder]} {
387
+ focus [searchbar::editor $finder]
388
+ } else {
389
+ focus $win
390
+ }
391
+}
392
+
393
method _handle_destroy {win} {
394
if {$win eq $w} {
395
_kill $this
lib/search.tcl
+11
-3
@@ -19,11 +19,11 @@ constructor new {i_w i_text args} {
19
20
frame $w
21
label $w.l -text [mc Find:]
22
+ entry $w.ent -textvariable ${__this}::searchstring -background lightgreen
23
button $w.bn -text [mc Next] -command [cb find_next]
24
button $w.bp -text [mc Prev] -command [cb find_prev]
25
checkbutton $w.cs -text [mc Case-Sensitive] \
26
-variable ${__this}::casesensitive -command [cb _incrsearch]
26
- entry $w.ent -textvariable ${__this}::searchstring -background lightgreen
27
pack $w.l -side left
28
pack $w.cs -side right
29
pack $w.bp -side right
@@ -40,19 +40,27 @@ constructor new {i_w i_text args} {
40
}
41
42
method show {} {
43
- if {![winfo ismapped $w]} {
43
+ if {![visible $this]} {
44
grid $w
45
}
46
focus -force $w.ent
47
}
48
49
method hide {} {
50
- if {[winfo ismapped $w]} {
50
+ if {[visible $this]} {
51
focus $ctext
52
grid remove $w
53
}
54
}
55
56
+method visible {} {
57
+ return [winfo ismapped $w]
58
+}
59
+
60
+method editor {} {
61
+ return $w.ent
62
+}
63
+
64
method _get_new_anchor {} {
65
# use start of selection if it is visible,
66
# or the bounds of the visible area