Announcement

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

    TabSelectedHandler

    We'd like to add a dummy tab at the end of a TabSet that acts as an "Add Tab" button.

    I've included two questions embedded below in the code sample for which I am looking for some guidance. I have also included a screen capture to demonstrate how the code displays.

    SmartClient Version: v9.1p_2014-06-30/Pro Deployment (built 2014-06-30)

    Thanks

    Code:
    public class PanelLayout extends VLayout {
    
        public PanelLayout() {
            setTitle("Panels");
            setLayoutBottomMargin(10);
            setLayoutRightMargin(5);
            TabSet tabSet = new TabSet();
            tabSet.setTabBarPosition(Side.BOTTOM);
            tabSet.setWidth100();
            tabSet.setHeight100();
            addMember(tabSet);
            Tab panelA = new Tab("Panel A");
            Tab panelB = new Tab("Panel B");
            Tab addPanel = new Tab("+"); // 1. Want to autofit title for this specific tab title.
            addPanel.addTabSelectedHandler(new TabSelectedHandler() {
    
                @Override
                public void onTabSelected(TabSelectedEvent event) {
                    // 2. Do not select "this" tab when clicked. (i.e. be able to call event.cancel()). Is there a way to do this?
    
                    // Prompt for details from user.
    
                    // Create new tab based on data provided by user.
    
                    // Add new tab before "this" tab so "this" tab always remains at the end.
                }
            });
            tabSet.addTab(panelA);
            tabSet.addTab(panelB);
            tabSet.addTab(addPanel);
        }
    }
    Attached Files

    #2
    Don't do any of this, just use tabBarControls. Much simpler, you don't have to deal with customizing all the behaviors of a tab to make not really a tab.

    Comment


      #3
      Thank you. I will use this approach.

      Comment

      Working...
      X