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
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.
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
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.
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
Time permitting, will try and reproduce the problem in a small sample.
Real code is better than pseudo code.