pivot-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chris Bartlett <cbartlet...@gmail.com>
Subject Re: TabPaneSelectionListener#selectedIndexChanged called twice when first tab is inserted
Date Sun, 05 Jun 2011 16:49:31 GMT
I had a quick look and feel that the 2nd notification seems wrong (where the
event's previousSelectedIndex is 0 while the TabPane's current selected
index is also 0)

However, CardPane and Accordion behave in the same way, so any changes to
TabPane should also be made to these for consistency.

I think it makes more sense to suppress the 2nd notification rather than
leaving the user to deal with it, but I don't know how much of a problem
this is in reality.  Perhaps just documenting the behaviour would be
sufficient?

Any comments from others on the mailing list?

Chris

On 4 June 2011 14:31, Edvin Syse <edvin@sysedata.no> wrote:

> I'm wondering if this is as intended or a bug:
>
> When I add a tab to an _empty_ tabpane, two selectedIndexChanged events are
> called. I.e, when I add a TabPaneSelectionListener to a tabpane and call:
>
> tabpane.getTabs().add(component);
>
> .. my listener fires twice, with previousSelectedIndex set to -1 and then
> 0.
>
> The two events are fired by line 68 and 72 in TabPane.java:
>
> 68            tabPaneListeners.tabInserted(TabPane.this, index);
> 69
> 70            // Fire selection change event, if necessary
> 71            if (selectedIndex != previousSelectedIndex) {
> 72 tabPaneSelectionListeners.selectedIndexChanged(TabPane.this,
> selectedIndex);
> 73            }
>
> Should the if on line 71 take into account that previousSelectedIndex might
> have been -1 when invoked, like this:
>
> if (selectedIndex != previousSelectedIndex && previousSelectedIndex > -1)
{
>
> .. to avoid the double event notification?
>
> -- Edvin
>

Mime
View raw message