in reply to Re^2: Tkx treeview setting focus
in thread Tkx treeview setting focus

Sorry you had trouble...try this complete mini-program
use Tkx; my $mw = Tkx::widget->new("."); #std line $frm_main= $mw->new_frame(); #parent widg probably a frame outsi +de of this compound control $frm_main->g_pack( -expand => 0, -fill => 'x', -side => top); my $tree=$frm_main->new_ttk__treeview; #http://www.tkdocs.com/tut +orial/tree.html $tree->g_pack( -expand => 0, -fill => 'x', -side => top); $gLast_id="root"; $gLast_id=$tree->insert("", "end", -id => $gLast_id, -text => "roo +t"); $tree->item($gLast_id, -open => "true"); #$tree->focus($gLast_id); $tree->g_bind( "<Insert>", sub { $gLast_id=$tree->insert($gLast_id, "end", -text => "some_text +" ); $tree->item($gLast_id, -open => "true"); #http://www.tkdocs.co +m/tutorial/tree.html #$tree->focus($gLast_id); }); Tkx::MainLoop();

Replies are listed 'Best First'.
Re^4: Tkx treeview setting focus
by Anonymous Monk on Apr 19, 2016 at 06:47 UTC

    Your program works for me, if the tree control has focus, and I hit insert, then the newly added item has focus,  $tree->focus($gLast_id) worked

    You can give the widget focus with  $tree->g_focus;

    Does that help?