I found the solution I needed from the archive dated June 8, 2005 (wow!) This is great, because now I can "close" my tabs in my TabNavigator.
There are 2 other problems, though:
1. if I create a new child, the previously "closed" tab re-appears as a tab-less child. So visually, I have tab0, then a gap for tab1, then tab2. Is there a way to keep the closed tab hidden and width=0? Do I have to track which tabs are close and set the visibility=false and width=0 all over again?
2. Is there a way to re-order the tabs? Say, I close tab1. Open tab2. Then reopen tab1. How can I put tab1 appears after tab2, instead of placing it between tab0 and tab2? I tried destroyChild, but I can't seem to resurrect the child... :| Yikes...
Any guide is greatly appreciated.
- ptrisnadi
> I think you're going to run into a few more complications.
>
> When you 'close' the tab, as I learned from Ali, you'll really have to do the following:
>
> Set the tab's visibility to false.
> Set the tab's width to 0.
>
> However, when you resize the stage, you're going to run into another issue. Flex is going to recalculate the tabbar and then rebuild the tabs. So invisible tabs will suddenly have a new width. You'll need to add a resize handler that determines which tabs are 'closed' or by this point, for your user, since the tabs will have a visibility of false, set their size to 0 again.
>
> Then, you'll see the tabbar freaks out and spaces the tabs in a staggered format. To get around this, your resize handler needs to get a width to set the size of the tabbar. I'd use the width of the parent tabnavigator and do the following:
> -----------------------------------------------------------------------------------
> view.appView['tabBar'].setSize(view.appView.width,'22');
>
> And to remove the tabs, you'll need something like:
> ------------------------------------------------------------------------------------
> public function setNavigation() : Void {
>
> var tab0 = view.appView["tabBar"].getChildAt(0);
> var tab1 = view.appView["tabBar"].getChildAt(1);
>
> tab0.visible = false;
> tab0.width = 0;
> tab1.visible = false;
> tab1.width = 0;
>
> view.appView['tabBar'].setSize(view.appView.width,'22');
> }
>
> On click, you can get the
>
> selectedIndex
>
> of the tab that was clicked, and pass it over to the setNavigator function as a parameter and set the visiblity to false and size to 0.
>
> Dave
>
>
> On 6/8/05, Eric Raymond <[EMAIL PROTECTED]> wrote:
>
> Each tab correponds to a view (in a viewstack).
>
>
> --- In flexcoders@yahoogroups.com, dave buhler <[EMAIL PROTECTED]> wrote:
> > Hi Eric,
> >
> > Are the tabs specific to an underlying view or are the tabs meant to be
> > closeButtons, similar to what you might find for a TitleWindow?
> >
> > Dave
> >
> > On 6/7/05, Eric Raymond <[EMAIL PROTECTED]> wrote:
> > >
> > > Is there a way to add a close button to a tab in a tabbar?
> > >
> > > That is, we'd like to put a graphic image of an "x" in some tabs in
> > > our application that are "closeable".
> > >
> > > I think there are two issues here:
> > >
> > > 1) Adding an extra icon to the tab
> > >
> > > As a hack, we could get away with "prepending" the close image the
> > > existing tab icon.
> > >
> > >
> > > 2) Detecting a click in the close icon
> > >
> > > As far as I know, the tabbar grabs all mouse/click events.
> > >
> > >
> > > Any ideas?
There are 2 other problems, though:
1. if I create a new child, the previously "closed" tab re-appears as a tab-less child. So visually, I have tab0, then a gap for tab1, then tab2. Is there a way to keep the closed tab hidden and width=0? Do I have to track which tabs are close and set the visibility=false and width=0 all over again?
2. Is there a way to re-order the tabs? Say, I close tab1. Open tab2. Then reopen tab1. How can I put tab1 appears after tab2, instead of placing it between tab0 and tab2? I tried destroyChild, but I can't seem to resurrect the child... :| Yikes...
Any guide is greatly appreciated.
- ptrisnadi
> I think you're going to run into a few more complications.
>
> When you 'close' the tab, as I learned from Ali, you'll really have to do the following:
>
> Set the tab's visibility to false.
> Set the tab's width to 0.
>
> However, when you resize the stage, you're going to run into another issue. Flex is going to recalculate the tabbar and then rebuild the tabs. So invisible tabs will suddenly have a new width. You'll need to add a resize handler that determines which tabs are 'closed' or by this point, for your user, since the tabs will have a visibility of false, set their size to 0 again.
>
> Then, you'll see the tabbar freaks out and spaces the tabs in a staggered format. To get around this, your resize handler needs to get a width to set the size of the tabbar. I'd use the width of the parent tabnavigator and do the following:
> -----------------------------------------------------------------------------------
> view.appView['tabBar'].setSize(view.appView.width,'22');
>
> And to remove the tabs, you'll need something like:
> ------------------------------------------------------------------------------------
> public function setNavigation() : Void {
>
> var tab0 = view.appView["tabBar"].getChildAt(0);
> var tab1 = view.appView["tabBar"].getChildAt(1);
>
> tab0.visible = false;
> tab0.width = 0;
> tab1.visible = false;
> tab1.width = 0;
>
> view.appView['tabBar'].setSize(view.appView.width,'22');
> }
>
> On click, you can get the
>
> selectedIndex
>
> of the tab that was clicked, and pass it over to the setNavigator function as a parameter and set the visiblity to false and size to 0.
>
> Dave
>
>
> On 6/8/05, Eric Raymond <[EMAIL PROTECTED]> wrote:
>
> Each tab correponds to a view (in a viewstack).
>
>
> --- In flexcoders@yahoogroups.com, dave buhler <[EMAIL PROTECTED]> wrote:
> > Hi Eric,
> >
> > Are the tabs specific to an underlying view or are the tabs meant to be
> > closeButtons, similar to what you might find for a TitleWindow?
> >
> > Dave
> >
> > On 6/7/05, Eric Raymond <[EMAIL PROTECTED]> wrote:
> > >
> > > Is there a way to add a close button to a tab in a tabbar?
> > >
> > > That is, we'd like to put a graphic image of an "x" in some tabs in
> > > our application that are "closeable".
> > >
> > > I think there are two issues here:
> > >
> > > 1) Adding an extra icon to the tab
> > >
> > > As a hack, we could get away with "prepending" the close image the
> > > existing tab icon.
> > >
> > >
> > > 2) Detecting a click in the close icon
> > >
> > > As far as I know, the tabbar grabs all mouse/click events.
> > >
> > >
> > > Any ideas?
--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
SPONSORED LINKS
Web site design development | Computer software development | Software design and development |
Macromedia flex | Software development best practice |
YAHOO! GROUPS LINKS
- Visit your group "flexcoders" on the web.
- To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
- Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.