You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@pivot.apache.org by Mathias Versichele <ma...@gmail.com> on 2010/02/25 21:06:58 UTC

Tableview auto-scroll to bottom

How do you make a tableview automatically scroll to the bottom when new rows
are added ?

-- 
Mathias Versichele
Bio-ir milieutechnologie / Msc. geografie
Oudburgstraat 16
9240 Zele
0485/16.07.08

Re: Tableview auto-scroll to bottom

Posted by Todd Volkert <tv...@gmail.com>.
No problem :)

Basically, components are sized and positioned (and painted) on a separate
event loop than your application code (for performance reasons).  So if you
add data to your table data, the table view says "I'll need to grow myself
to accommodate this new data... but I'll wait until the next event loop".
Thus, *immediately* after you add that table data, the table view is smaller
than it needs to be.  So if you tell it to scroll to the bottom, it'll only
scroll to the bottom based on its too-small size.  By queueing a callback,
you're saying "let the table view grow to its needed size, *then* scroll to
the bottom".

You won't run into these cases that often, but they come up every now and
then.

-T

On Fri, Feb 26, 2010 at 6:15 AM, Mathias Versichele <
mathias.versichele@gmail.com> wrote:

> Don't exactly know what that code does, but it works :-) Thanks
>
> 2010/2/26 Todd Volkert <tv...@gmail.com>
>
> My guess is that you're calling this after the table view has been
>> invalidated but before it's been laid out.  In cases such as these, you have
>> to queue a callback, like this:
>>
>> ApplicationContext.queueCallback(new Runnable() {
>>     @Override
>>     public void run() {
>>         // Perform scrolling here
>>     }
>> });
>>
>> Cheers,
>> -T
>>
>>
>> On Fri, Feb 26, 2010 at 3:05 AM, Mathias Versichele <
>> mathias.versichele@gmail.com> wrote:
>>
>>> I'm not calling it in response to a Task Listener, and I can navigate to
>>> the bottom with the arrow keys without any problems.
>>>
>>>
>>> 2010/2/25 Greg Brown <gk...@mac.com>
>>>
>>>> Another question - can you use the arrow keys to navigate to the last
>>>> row?
>>>>
>>>> On Feb 25, 2010, at 3:40 PM, Mathias Versichele wrote:
>>>>
>>>> It gets stuck about 6 rows from the bottom, so it doesn't work
>>>> perfectly...
>>>>
>>>> 2010/2/25 Greg Brown <gk...@mac.com>
>>>>
>>>>> Try this, let me know if it doesn't work:
>>>>>
>>>>>   int n = tableView.getTableData().getLength() - 1;
>>>>>   tableView.scrollAreaToVisible(tableView.getRowBounds(n));
>>>>>
>>>>>
>>>>> On Feb 25, 2010, at 3:06 PM, Mathias Versichele wrote:
>>>>>
>>>>> How do you make a tableview automatically scroll to the bottom when new
>>>>> rows are added ?
>>>>>
>>>>> --
>>>>> Mathias Versichele
>>>>> Bio-ir milieutechnologie / Msc. geografie
>>>>> Oudburgstraat 16
>>>>> 9240 Zele
>>>>> 0485/16.07.08
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>> --
>>>> Mathias Versichele
>>>> Bio-ir milieutechnologie / Msc. geografie
>>>> Oudburgstraat 16
>>>> 9240 Zele
>>>> 0485/16.07.08
>>>>
>>>>
>>>>
>>>
>>>
>>> --
>>> Mathias Versichele
>>> Bio-ir milieutechnologie / Msc. geografie
>>> Oudburgstraat 16
>>> 9240 Zele
>>> 0485/16.07.08
>>>
>>
>>
>
>
> --
> Mathias Versichele
> Bio-ir milieutechnologie / Msc. geografie
> Oudburgstraat 16
> 9240 Zele
> 0485/16.07.08
>

Re: Tableview auto-scroll to bottom

Posted by Mathias Versichele <ma...@gmail.com>.
Don't exactly know what that code does, but it works :-) Thanks

2010/2/26 Todd Volkert <tv...@gmail.com>

> My guess is that you're calling this after the table view has been
> invalidated but before it's been laid out.  In cases such as these, you have
> to queue a callback, like this:
>
> ApplicationContext.queueCallback(new Runnable() {
>     @Override
>     public void run() {
>         // Perform scrolling here
>     }
> });
>
> Cheers,
> -T
>
>
> On Fri, Feb 26, 2010 at 3:05 AM, Mathias Versichele <
> mathias.versichele@gmail.com> wrote:
>
>> I'm not calling it in response to a Task Listener, and I can navigate to
>> the bottom with the arrow keys without any problems.
>>
>>
>> 2010/2/25 Greg Brown <gk...@mac.com>
>>
>>> Another question - can you use the arrow keys to navigate to the last
>>> row?
>>>
>>> On Feb 25, 2010, at 3:40 PM, Mathias Versichele wrote:
>>>
>>> It gets stuck about 6 rows from the bottom, so it doesn't work
>>> perfectly...
>>>
>>> 2010/2/25 Greg Brown <gk...@mac.com>
>>>
>>>> Try this, let me know if it doesn't work:
>>>>
>>>>   int n = tableView.getTableData().getLength() - 1;
>>>>   tableView.scrollAreaToVisible(tableView.getRowBounds(n));
>>>>
>>>>
>>>> On Feb 25, 2010, at 3:06 PM, Mathias Versichele wrote:
>>>>
>>>> How do you make a tableview automatically scroll to the bottom when new
>>>> rows are added ?
>>>>
>>>> --
>>>> Mathias Versichele
>>>> Bio-ir milieutechnologie / Msc. geografie
>>>> Oudburgstraat 16
>>>> 9240 Zele
>>>> 0485/16.07.08
>>>>
>>>>
>>>>
>>>
>>>
>>> --
>>> Mathias Versichele
>>> Bio-ir milieutechnologie / Msc. geografie
>>> Oudburgstraat 16
>>> 9240 Zele
>>> 0485/16.07.08
>>>
>>>
>>>
>>
>>
>> --
>> Mathias Versichele
>> Bio-ir milieutechnologie / Msc. geografie
>> Oudburgstraat 16
>> 9240 Zele
>> 0485/16.07.08
>>
>
>


-- 
Mathias Versichele
Bio-ir milieutechnologie / Msc. geografie
Oudburgstraat 16
9240 Zele
0485/16.07.08

Re: Tableview auto-scroll to bottom

Posted by Todd Volkert <tv...@gmail.com>.
My guess is that you're calling this after the table view has been
invalidated but before it's been laid out.  In cases such as these, you have
to queue a callback, like this:

ApplicationContext.queueCallback(new Runnable() {
    @Override
    public void run() {
        // Perform scrolling here
    }
});

Cheers,
-T

On Fri, Feb 26, 2010 at 3:05 AM, Mathias Versichele <
mathias.versichele@gmail.com> wrote:

> I'm not calling it in response to a Task Listener, and I can navigate to
> the bottom with the arrow keys without any problems.
>
>
> 2010/2/25 Greg Brown <gk...@mac.com>
>
>> Another question - can you use the arrow keys to navigate to the last row?
>>
>> On Feb 25, 2010, at 3:40 PM, Mathias Versichele wrote:
>>
>> It gets stuck about 6 rows from the bottom, so it doesn't work
>> perfectly...
>>
>> 2010/2/25 Greg Brown <gk...@mac.com>
>>
>>> Try this, let me know if it doesn't work:
>>>
>>>   int n = tableView.getTableData().getLength() - 1;
>>>   tableView.scrollAreaToVisible(tableView.getRowBounds(n));
>>>
>>>
>>> On Feb 25, 2010, at 3:06 PM, Mathias Versichele wrote:
>>>
>>> How do you make a tableview automatically scroll to the bottom when new
>>> rows are added ?
>>>
>>> --
>>> Mathias Versichele
>>> Bio-ir milieutechnologie / Msc. geografie
>>> Oudburgstraat 16
>>> 9240 Zele
>>> 0485/16.07.08
>>>
>>>
>>>
>>
>>
>> --
>> Mathias Versichele
>> Bio-ir milieutechnologie / Msc. geografie
>> Oudburgstraat 16
>> 9240 Zele
>> 0485/16.07.08
>>
>>
>>
>
>
> --
> Mathias Versichele
> Bio-ir milieutechnologie / Msc. geografie
> Oudburgstraat 16
> 9240 Zele
> 0485/16.07.08
>

Re: Tableview auto-scroll to bottom

Posted by Mathias Versichele <ma...@gmail.com>.
I'm not calling it in response to a Task Listener, and I can navigate to the
bottom with the arrow keys without any problems.

2010/2/25 Greg Brown <gk...@mac.com>

> Another question - can you use the arrow keys to navigate to the last row?
>
> On Feb 25, 2010, at 3:40 PM, Mathias Versichele wrote:
>
> It gets stuck about 6 rows from the bottom, so it doesn't work perfectly...
>
> 2010/2/25 Greg Brown <gk...@mac.com>
>
>> Try this, let me know if it doesn't work:
>>
>>   int n = tableView.getTableData().getLength() - 1;
>>   tableView.scrollAreaToVisible(tableView.getRowBounds(n));
>>
>>
>> On Feb 25, 2010, at 3:06 PM, Mathias Versichele wrote:
>>
>> How do you make a tableview automatically scroll to the bottom when new
>> rows are added ?
>>
>> --
>> Mathias Versichele
>> Bio-ir milieutechnologie / Msc. geografie
>> Oudburgstraat 16
>> 9240 Zele
>> 0485/16.07.08
>>
>>
>>
>
>
> --
> Mathias Versichele
> Bio-ir milieutechnologie / Msc. geografie
> Oudburgstraat 16
> 9240 Zele
> 0485/16.07.08
>
>
>


-- 
Mathias Versichele
Bio-ir milieutechnologie / Msc. geografie
Oudburgstraat 16
9240 Zele
0485/16.07.08

Re: Tableview auto-scroll to bottom

Posted by Greg Brown <gk...@mac.com>.
Another question - can you use the arrow keys to navigate to the last row?

On Feb 25, 2010, at 3:40 PM, Mathias Versichele wrote:

> It gets stuck about 6 rows from the bottom, so it doesn't work perfectly...
> 
> 2010/2/25 Greg Brown <gk...@mac.com>
> Try this, let me know if it doesn't work:
> 
>   int n = tableView.getTableData().getLength() - 1;
>   tableView.scrollAreaToVisible(tableView.getRowBounds(n));
> 
> 
> On Feb 25, 2010, at 3:06 PM, Mathias Versichele wrote:
> 
>> How do you make a tableview automatically scroll to the bottom when new rows are added ?
>> 
>> -- 
>> Mathias Versichele
>> Bio-ir milieutechnologie / Msc. geografie
>> Oudburgstraat 16
>> 9240 Zele
>> 0485/16.07.08
> 
> 
> 
> 
> -- 
> Mathias Versichele
> Bio-ir milieutechnologie / Msc. geografie
> Oudburgstraat 16
> 9240 Zele
> 0485/16.07.08


Re: Tableview auto-scroll to bottom

Posted by Greg Brown <gk...@mac.com>.
Hm, that's odd. Are you calling it in response to a task listener by any chance?

On Feb 25, 2010, at 3:40 PM, Mathias Versichele wrote:

> It gets stuck about 6 rows from the bottom, so it doesn't work perfectly...
> 
> 2010/2/25 Greg Brown <gk...@mac.com>
> Try this, let me know if it doesn't work:
> 
>   int n = tableView.getTableData().getLength() - 1;
>   tableView.scrollAreaToVisible(tableView.getRowBounds(n));
> 
> 
> On Feb 25, 2010, at 3:06 PM, Mathias Versichele wrote:
> 
>> How do you make a tableview automatically scroll to the bottom when new rows are added ?
>> 
>> -- 
>> Mathias Versichele
>> Bio-ir milieutechnologie / Msc. geografie
>> Oudburgstraat 16
>> 9240 Zele
>> 0485/16.07.08
> 
> 
> 
> 
> -- 
> Mathias Versichele
> Bio-ir milieutechnologie / Msc. geografie
> Oudburgstraat 16
> 9240 Zele
> 0485/16.07.08


Re: Tableview auto-scroll to bottom

Posted by Mathias Versichele <ma...@gmail.com>.
It gets stuck about 6 rows from the bottom, so it doesn't work perfectly...

2010/2/25 Greg Brown <gk...@mac.com>

> Try this, let me know if it doesn't work:
>
>   int n = tableView.getTableData().getLength() - 1;
>   tableView.scrollAreaToVisible(tableView.getRowBounds(n));
>
>
> On Feb 25, 2010, at 3:06 PM, Mathias Versichele wrote:
>
> How do you make a tableview automatically scroll to the bottom when new
> rows are added ?
>
> --
> Mathias Versichele
> Bio-ir milieutechnologie / Msc. geografie
> Oudburgstraat 16
> 9240 Zele
> 0485/16.07.08
>
>
>


-- 
Mathias Versichele
Bio-ir milieutechnologie / Msc. geografie
Oudburgstraat 16
9240 Zele
0485/16.07.08

Re: Tableview auto-scroll to bottom

Posted by Greg Brown <gk...@mac.com>.
Try this, let me know if it doesn't work:

  int n = tableView.getTableData().getLength() - 1;
  tableView.scrollAreaToVisible(tableView.getRowBounds(n));

On Feb 25, 2010, at 3:06 PM, Mathias Versichele wrote:

> How do you make a tableview automatically scroll to the bottom when new rows are added ?
> 
> -- 
> Mathias Versichele
> Bio-ir milieutechnologie / Msc. geografie
> Oudburgstraat 16
> 9240 Zele
> 0485/16.07.08