Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    tab selection handler event only when user selects tab?

    I am usign a TabSet and added TabSelectedHandler event to it. On load, one if my tab is selected and this event is getting fired. I don't want that. I want only the event should be triggered in case of user clicks.

    I saw the API and there is another event called TabIconClickHandler, but this is not being triggered as I am not using any icon image for tabs. It's plain text.

    Is there anyway to achieve which I just explained? I know there is a source attached to the event. But I am not sure how I can use that.


    Thanks, Amit

    #2
    Well the expected behavior should be it fires at any point a tab is selected but check the event object it can let you know. In particular if the leftbutton isn't down or X value not valid you know it wasn't the user.

    Comment


      #3
      I agree with you but somehow the first time load is a little different for me. Anyway the suggestion which you gave does not work. Everything is set even when user is not clicking the tab. Please let me know if you have any more suggestion, else i will put some workaround.

      Thanks for the response.

      Comment


        #4
        They do work unless you are doing something funny. Run the simple test case below and note what gets printed when the tabset is drawn inside the selected handler. This is a clear giveaway the selection was not produced by user interaction.
        Code:
        TabSet t = new TabSet();
        t.addTabSelectedHandler(new TabSelectedHandler() {
          @Override
          public void onTabSelected(TabSelectedEvent event) {
            SC.logWarn("1: " + event.isLeftButtonDown());
            SC.logWarn("2: " + event.getX());
          }
        });
        Tab t1 = new Tab();
        t1.setTitle("A");
        Tab t2 = new Tab();
        t2.setTitle("B");
        t.setTabs(t1, t2);
        t.draw();

        Comment


          #5
          What I meant in my last post is that these values can't be used to identify the events origin. Even when user does not click, i am getting some +ve X values and left button down was also true.

          Comment


            #6
            What version are you on? That standalone test case gives you valid values? I get x to be undefined and left button to be false, expect when I physically click on a tab.

            Comment


              #7
              I am on the latest i.e. 2.2. I tested and i was getting some valid +ve value for X for the tab. (though it was different value when I click on the same tab)
              Last edited by asingla; 13 Oct 2010, 11:53.

              Comment

              Working...
              X