You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pivot.apache.org by Chris Bartlett <cb...@gmail.com> on 2010/08/26 18:56:48 UTC

TabPane closing & collapsing

I just looked through the TabPanes tutorial in trunk
/tutorials/src/org/apache/pivot/tutorials/navigation/TabPanes.java
/tutorials/src/org/apache/pivot/tutorials/navigation/tab_panes.bxml

The logic to select a tab after another one is closed, exists as a custom
TabPaneListener in TabPanes.java rather than in the TabPane component
itself.

Is it done this way because 'closing' a tab just results in a call to
TabSequence.remove()?
If so, perhaps it would be worth adding some sort of TabPane.closeTab(int
tabIndex) method which would close the tab and then reselect another (if
there is one). This is the behaviour I would expect, and perhaps many others
too.


On a vaguely similar theme, should there be user friendly methods for
handling the collapsed state of the TabPane?
- tabPane.setCollapsed(boolean collapsed)
- tabPane.isCollapsed()

rather than
- tabPane.setSelectedIndex(-1 / 0..n)
- ((tabPane.getSelectedIndex() == -1) && isCollapsible())

At the least we need to document the significance of setting the selected
tab index to -1 or 0..n;

Chris

Re: TabPane closing & collapsing

Posted by Chris Bartlett <cb...@gmail.com>.
Thanks for the quick response.
OK, I will add a a JIRA ticket and then try to put in the changes tomorrow.

Chris

On 27 August 2010 00:01, Greg Brown <gk...@mac.com> wrote:

> Good points. Comments below:
>
> > The logic to select a tab after another one is closed, exists as a custom
> > TabPaneListener in TabPanes.java rather than in the TabPane component
> > itself.
> >
> > Is it done this way because 'closing' a tab just results in a call to
> > TabSequence.remove()?
>
> Yes - but maybe we should be smarter about it. We automatically select the
> first tab that is added to a TabPane; perhaps we should automatically select
> the next (or previous, if none is available) tab when a tab is closed. Same
> logic could apply to Accordion. Then users wouldn't need the custom
> listener.
>
> > On a vaguely similar theme, should there be user friendly methods for
> > handling the collapsed state of the TabPane?
> > - tabPane.setCollapsed(boolean collapsed)
> > - tabPane.isCollapsed()
> >
> > rather than
> > - tabPane.setSelectedIndex(-1 / 0..n)
> > - ((tabPane.getSelectedIndex() == -1) && isCollapsible())
>
> I think this is a good idea. "collapsible" used to be a style property, so
> such a method wouldn't have made sense. I think it would now, though.
>
> Feel free to exercise your new commit privileges on these changes.  :-)
>
> G
>
>

Re: TabPane closing & collapsing

Posted by Greg Brown <gk...@mac.com>.
Good points. Comments below:

> The logic to select a tab after another one is closed, exists as a custom
> TabPaneListener in TabPanes.java rather than in the TabPane component
> itself.
> 
> Is it done this way because 'closing' a tab just results in a call to
> TabSequence.remove()?

Yes - but maybe we should be smarter about it. We automatically select the first tab that is added to a TabPane; perhaps we should automatically select the next (or previous, if none is available) tab when a tab is closed. Same logic could apply to Accordion. Then users wouldn't need the custom listener.

> On a vaguely similar theme, should there be user friendly methods for
> handling the collapsed state of the TabPane?
> - tabPane.setCollapsed(boolean collapsed)
> - tabPane.isCollapsed()
> 
> rather than
> - tabPane.setSelectedIndex(-1 / 0..n)
> - ((tabPane.getSelectedIndex() == -1) && isCollapsible())

I think this is a good idea. "collapsible" used to be a style property, so such a method wouldn't have made sense. I think it would now, though.

Feel free to exercise your new commit privileges on these changes.  :-)

G