Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

auto-refreshing <tree>

3 views
Skip to first unread message

Krishna

unread,
Dec 26, 2009, 4:02:18 AM12/26/09
to
Hi all,

I'm new to the mozilla platform and am working on my first XUL app. I
need to periodically refresh a tree backed by a custom nsITreeView.
I've tried calling the invalidate* methods on the tree's box object
from a timer which fires every 5 seconds. However, the tree is not
redrawn. It is redrawn only when there are additional events like a
mouse hovering on the tree etc.

How do I force an update event on the tree?

Thanks in advance,
--Krishna

Vasu

unread,
Dec 26, 2009, 8:18:19 PM12/26/09
to
This might work for you.

https://developer.mozilla.org/En/DOM/Node.removeChild

Just redraw the complete tree every 5secs. If there are lot of nodes
that you need to worry about, then maintain a cache which have the
value changed and only remove /redraw them.

Krishna

unread,
Dec 27, 2009, 1:42:57 AM12/27/09
to
On Dec 27, 6:18 am, Vasu <vas...@gmail.com> wrote:
> This might work for you.
>
> https://developer.mozilla.org/En/DOM/Node.removeChild
>

Are you suggesting to remove the tree and insert it back? That sounds
very inefficient.

The tree data is maintained outside of the DOM by an object
implementing nsITreeView.

> Just redraw the complete tree every 5secs.

That is my question. The invalidate method on the tree's box object is
not forcing a redraw.

> If there are lot of nodes
> that you need to worry about, then maintain a cache which have the
> value changed and only remove /redraw them.

Yes, but again the invalidateRange and invalidateRow methods are not
refreshing either.

Are timers run on separate threads? If so is there a way to post
events into the main/gui thread?

A note in the tutorial on trees says:

"Note that redrawing does not occur until the calling script ends
since Mozilla does not redraw in the background."

I'm not quite clear on what is meant by the "calling script ends". In
my case, is it the timer's callback?

Thanks,
--Krishna

Vasu

unread,
Dec 27, 2009, 5:59:16 AM12/27/09
to
Does single invalidateRow work ok - w/o setTimeout? Explicitly calling
invalidateRow?

If above is true, try setInterval - which is slight different
implementation. If single invalidateRow itself is not working then you
have a different issue to deal with.

On the other question, I just checked on the threads, I don't think
timers are on seperate threads.

If all fail, as a workaround, I would even try to simulate mouse
events as it is working. createEvent is what you might wanna
consider.

Krishna

unread,
Dec 27, 2009, 6:20:16 AM12/27/09
to
On Dec 27, 3:59 pm, Vasu <vas...@gmail.com> wrote:
> Does single invalidateRow work ok - w/o setTimeout? Explicitly calling
> invalidateRow?
>

nope.

> If above is true, try setInterval - which is slight different
> implementation. If single invalidateRow itself is not working then you
> have a different issue to deal with.
>

I'm using setInterval.

> On the other question, I just checked on the threads, I don't think
> timers are on seperate threads.
>
> If all fail, as a workaround, I would even try to simulate mouse
> events as it is working. createEvent is what you might wanna
> consider.

Tried creating and sending a mousemove event and that din't work.

Finally, added an additional invalidate() to the callback (the
invalidate[Cell,Row,Range] were inside a function that was called from
the callback) and that seems to have solved the problem although I
don't understand why it works now and why it din't work earlier.

Thanks for your inputs,
--Krishna

Vasu

unread,
Dec 27, 2009, 2:29:12 PM12/27/09
to
Glad it is working finally. If you want to know why it didn't work,
share the pseudo code, might get some pointers.

Krishna

unread,
Dec 28, 2009, 11:44:32 AM12/28/09
to
On Dec 28, 12:29 am, Vasu <vas...@gmail.com> wrote:
> Glad it is working finally. If you want to know why it didn't work,
> share the pseudo code, might get some pointers.

Time permitting, will try and reproduce the problem in a small sample.
Real code is better than pseudo code.

0 new messages