I wrote a small example of my problem below. It's just a simple window with a Gtk2::Notebook that contains a few pages. When I change pages by clicking the tabs, the focus moves to the label on the new tab 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, 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?

Thanks,

Jim

#!/usr/bin/perl use strict; use warnings; use Gtk2 -init; my($win)=create(); Gtk2->main(); sub create { my($win,$book); $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); $win->show_all(); return $win; }

In reply to Unable To Control Focus In A Gtk2::Notebook by williams

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.