0

OnBlur of a TabPanel?

asked 2010-12-14 22:18:52 +0800

FujitsuConsulting gravatar image FujitsuConsulting
165 1

Hi All,

How would I add an event which captures the onBlur(?) (really de-focus) of a tab from one to another?

Ive tried:

    Tab t = mainWindow.getSelectedTab();

    t.addEventListener(Events.ON_BLUR, new EventListener()
    {
      public void onEvent( Event event ) throws UiException
      {
        System.out.println("BLUR TAB!!!!!!!!!!!!!!!!!>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<");
      }
    });

But it didnt work.

Thanks!

delete flag offensive retag edit

7 Replies

Sort by ยป oldest newest

answered 2010-12-15 01:55:00 +0800

samchuang gravatar image samchuang
4084 4

Hi

you can use tab onSelect event, when change tab.

link publish delete flag offensive edit

answered 2010-12-15 15:20:52 +0800

FujitsuConsulting gravatar image FujitsuConsulting
165 1

Thanks for that, but I want to add an event to the leaving tab.

For example:

TAB1 has a timer which is running, when the user moves to TAB2 I want the timer to stop

link publish delete flag offensive edit

answered 2010-12-15 18:34:06 +0800

samchuang gravatar image samchuang
4084 4

Hi

I see, you can still use onSelect event.

first, when init, you save which tab has selected, when onSelect event trigger, you can know the last tab

link publish delete flag offensive edit

answered 2010-12-16 16:58:33 +0800

FujitsuConsulting gravatar image FujitsuConsulting
165 1

That sounds good - thanks samchuang.

Okay, another Tab question:

Say you have 2 tabs open and the second one selected. You close the second one and ZK changes the focus to the first one, this doesnt fired on the onSelect Event, how do I capture this event? (The Tabs are dynamically created)

link publish delete flag offensive edit

answered 2010-12-16 19:21:23 +0800

FujitsuConsulting gravatar image FujitsuConsulting
165 1

Think Ive figured it out:

Pseudo code:

// * Find the next tab which will be selected after this one is closed
// * Save the index of the next selected tab
// * Find the tab box of the next selected tab
// * Find the tab panels from the tab box
// * Loop thru the tab panels and check their index with the next selected tab's index

    tab.addEventListener(Events.ON_CLOSE, new EventListener()
    {
      public void onEvent( Event event ) throws UiException
      {
        // Because there is no direct link between Tabs and a TabPanel, we need to
        // do the following:
        // * Find the next tab which will be selected after this one is closed
        // * Save the index of the next selected tab
        // * Find the tab box of the next selected tab
        // * Find the tab panels from the tab box
        // * Loop thru the tab panels and check their index with the next selected tab's index
        
        Tab nextSelectedTab = null;

        for (Tab nextTab = (Tab)tab.getNextSibling(); nextTab != null; nextTab = (Tab)nextTab.getNextSibling())
          if (!nextTab.isDisabled())
          {
            nextSelectedTab = nextTab;
            break;
          }
        if (nextSelectedTab == null)
        {
          for (Tab nextTab = (Tab)tab.getPreviousSibling(); nextTab != null; nextTab = (Tab)nextTab
              .getPreviousSibling())
            if (!nextTab.isDisabled())
            {
              nextSelectedTab = nextTab;
              break;
            }
        }

        // we should alway have a next selected tab as we have the non-closeable Home Tab
        if (nextSelectedTab != null)
        {
          FWWindow win = null;
          int tabIndex = nextSelectedTab.getIndex();
          Tabpanel nextSelectedTabPanel = null;
          Tabbox tabBox = nextSelectedTab.getTabbox();
          Tabpanels tps = tabBox.getTabpanels();
          List tpsChildren = tps.getChildren();

          for (Object o : tpsChildren)
          {
            if (o instanceof Tabpanel)
            {
              Tabpanel tp = (Tabpanel)o;
              if (tp.getIndex() == tabIndex)
              {
                nextSelectedTabPanel = tp;
                break;
              }
            }
          }
        }

      }
    });

link publish delete flag offensive edit

answered 2010-12-16 20:34:50 +0800

samchuang gravatar image samchuang
4084 4

updated 2010-12-16 20:35:05 +0800

looks great~

thanks for sharing your code

link publish delete flag offensive edit

answered 2013-01-07 10:21:36 +0800

adelmo gravatar image adelmo
3

My problem is this: i have a page with borderlayout with a combobox in the north.
When i select an option i load different tabbox in the south. How can i intercept blur of tab box in this case? My problem is that doesn't fire onSelect or onClose when i change tabbox from combo.
Workaround is work on change of combo, but if i can intercept blur of tab i can work only on tab object ...

thx

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2010-12-14 22:18:52 +0800

Seen: 490 times

Last updated: Jan 07 '13

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More