blockcipher has asked for the wisdom of the Perl Monks concerning the following question:

I have an application where I'm using the Notebook widget and currently have 4 tabs. I want to be able to run some code every time a person switches to a tab. How can I do this?

I've tried several different ways I thought to do it using $nb->focus, $nb->info("active"), etc., but they all fire too early. In other words, if I'm already on the tab and I change, it runs the code for the tab I'm switching from, not to. I do see the changes when I go back to the node, but it's not acceptable.

Replies are listed 'Best First'.
Re: Notebook event question
by ikegami (Patriarch) on Feb 24, 2005 at 17:28 UTC

    From Tk::Notebook:

    info("focusnext")
    Return the page name of the tab which would receive the next focus.

    Have you tried this?

      Yep. The way it seems to work is the "next" tab to be focused is the one to the right of the tab. The function I'm trying to run on the first tab only runs when I click on the last tab. First being the left-most tab and last being the right-most tab.
        It was just something to try. Pity it didn't work.
Re: Notebook event question
by jdporter (Paladin) on Feb 24, 2005 at 18:29 UTC
    You want the -raisecmd option of the add and pageconfigure methods.
      Great! That works like a charm! Thanks! Though, I now feel like a tard for not seeing it earlier...oh well!