in reply to Tk::Notebook exclude tab from focus traversal

Here's a version that allows shift-tab to go backwards properly, that is, it works both forward and backwards.

#!/usr/bin/perl # use strict; use warnings; use Tk; require Tk::NoteBook; my $main = MainWindow->new( ); my $nb = $main->NoteBook(-takefocus => 0 )->pack(-expand => 1, -fill = +> 'both'); my $page1 = $nb->add('page1', -label => 'Page 1'); my $one = $page1->Entry()->pack(); $page1->Entry()->pack(); my $three = $page1->Entry()->pack(); $page1->Entry()->pack(); $three->bind('<Tab>' => sub { $main->after( 0, sub {$one->focus} ) } ) +; $one->bind('<<LeftTab>>' => sub { $main->after( 0, sub {$three->focus} + ) } ); $nb->add('page2', -label => 'Page 2'); MainLoop;

Replies are listed 'Best First'.
Re^2: Tk::Notebook exclude tab from focus traversal
by cscvrp (Novice) on Nov 27, 2018 at 05:28 UTC
    While it turns out the takefocus works if you just apply it to the right place as beech shows, this was very helpful in helping me think about managing focus, and I'm going to need this soon in some soon to tackle problems elsewhere. Thanks for your time, much appreciated!