Unable To Control Focus In A Gtk2::Notebook

I wrote a small example of my problem below.  It's just a simple window with a Gtk2::Notebook that contains a few pages, each with its own Gtk2::Entry.  When I change pages by clicking the tabs, the focus moves to the label on the new tab, but only if it was originally on the label of the previous tab. This is exactly what I want in all cases.

However, if the focus was originally somewhere inside the previous page, like one of the Gtk2::Entry widgets in the example below, the focus moves to a widget inside the new page.  Instead, I'd like the focus to always move to the label of the new tab.

I've tried attaching callbacks to different signals so I can call $w->grab_focus() on the label or notebook, but nothing seems to keep the focus on the new tab's label after page turns.  How can I make that happen?





use strict;

use warnings;


use Gtk2 -init;







sub create





   $win=new Gtk2::Window();

   $win->signal_connect(delete_event => sub {Gtk2->main_quit()});


   $win->add($book=new Gtk2::Notebook());


   $book->append_page(new Gtk2::Entry(),new Gtk2::Label($_))

      foreach qw(Goo Moo Foo);




   return $win;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]