{"thread":{"id":"16239","subject":"[PATCH (GIT-GUI)] git-gui: Fix focus transition in the blame viewer.","startedAt":"2008-11-09T15:36:50Z","lastAt":"2008-11-09T15:36:50Z","messageCount":1,"participants":["Alexander Gavrilov"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"95264","messageId":"200811091836.50832.angavrilov@gmail.com","threadId":"16239","inReplyTo":null,"subject":"[PATCH (GIT-GUI)] git-gui: Fix focus transition in the blame viewer.","fromName":"Alexander Gavrilov","fromEmail":"angavrilov@gmail.com","sentAt":"2008-11-09T15:36:50Z","receivedAt":"2008-11-09T15:36:50Z","isPatch":true,"sender":{"key":"angavrilov@gmail.com","avatar":"https://avatars.githubusercontent.com/u/42666?v=4"},"body":"Now that the blame viewer has a search panel, it should be\ntaken into account by the focus transition code. Otherwise\nshowing a commit tip (by accidentally moving the mouse to\nthe text frame) causes the focus to transfer away from the\nsearch field.\n\nSigned-off-by: Alexander Gavrilov <angavrilov@gmail.com>\n---\n lib/blame.tcl  |   16 ++++++++++++----\n lib/search.tcl |   14 +++++++++++---\n 2 files changed, 23 insertions(+), 7 deletions(-)\n\ndiff --git a/lib/blame.tcl b/lib/blame.tcl\nindex 765d08c..642f5ca 100644\n--- a/lib/blame.tcl\n+++ b/lib/blame.tcl\n@@ -321,7 +321,7 @@ constructor new {i_commit i_path i_jump} {\n \t\t\ttk_popup $w.ctxm %X %Y\n \t\t\"\n \t\tbind $i <Shift-Tab> \"[list focus $w_cviewer];break\"\n-\t\tbind $i <Tab>       \"[list focus $w_cviewer];break\"\n+\t\tbind $i <Tab>       \"[cb _focus_search $w_cviewer];break\"\n \t}\n \n \tforeach i [concat $w_columns $w_cviewer] {\n@@ -337,10 +337,10 @@ constructor new {i_commit i_path i_jump} {\n \t\tbind $i <Control-Key-f> {catch {%W yview scroll  1 pages};break}\n \t}\n \n-\tbind $w_cviewer <Shift-Tab> \"[list focus $w_file];break\"\n+\tbind $w_cviewer <Shift-Tab> \"[cb _focus_search $w_file];break\"\n \tbind $w_cviewer <Tab>       \"[list focus $w_file];break\"\n-\tbind $w_cviewer <Button-1> [list focus $w_cviewer]\n-\tbind $w_file    <Visibility> [list focus $w_file]\n+\tbind $w_cviewer <Button-1>   [list focus $w_cviewer]\n+\tbind $w_file    <Visibility> [cb _focus_search $w_file]\n \tbind $top       <F7>         [list searchbar::show $finder]\n \tbind $top       <Escape>     [list searchbar::hide $finder]\n \tbind $top       <F3>         [list searchbar::find_next $finder]\n@@ -382,6 +382,14 @@ constructor new {i_commit i_path i_jump} {\n \t_load $this $i_jump\n }\n \n+method _focus_search {win} {\n+\tif {[searchbar::visible $finder]} {\n+\t\tfocus [searchbar::editor $finder]\n+\t} else {\n+\t\tfocus $win\n+\t}\n+}\n+\n method _handle_destroy {win} {\n \tif {$win eq $w} {\n \t\t_kill $this\ndiff --git a/lib/search.tcl b/lib/search.tcl\nindex d292f20..32c8656 100644\n--- a/lib/search.tcl\n+++ b/lib/search.tcl\n@@ -19,11 +19,11 @@ constructor new {i_w i_text args} {\n \n \tframe  $w\n \tlabel  $w.l       -text [mc Find:]\n+\tentry  $w.ent -textvariable ${__this}::searchstring -background lightgreen\n \tbutton $w.bn      -text [mc Next] -command [cb find_next]\n \tbutton $w.bp      -text [mc Prev] -command [cb find_prev]\n \tcheckbutton $w.cs -text [mc Case-Sensitive] \\\n \t\t-variable ${__this}::casesensitive -command [cb _incrsearch]\n-\tentry  $w.ent -textvariable ${__this}::searchstring -background lightgreen\n \tpack   $w.l   -side left\n \tpack   $w.cs  -side right\n \tpack   $w.bp  -side right\n@@ -40,19 +40,27 @@ constructor new {i_w i_text args} {\n }\n \n method show {} {\n-\tif {![winfo ismapped $w]} {\n+\tif {![visible $this]} {\n \t\tgrid $w\n \t}\n \tfocus -force $w.ent\n }\n \n method hide {} {\n-\tif {[winfo ismapped $w]} {\n+\tif {[visible $this]} {\n \t\tfocus $ctext\n \t\tgrid remove $w\n \t}\n }\n \n+method visible {} {\n+\treturn [winfo ismapped $w]\n+}\n+\n+method editor {} {\n+\treturn $w.ent\n+}\n+\n method _get_new_anchor {} {\n \t# use start of selection if it is visible,\n \t# or the bounds of the visible area\n-- \n1.6.0.3.15.gb8d36\n"}]}