On 22/03/2015 16:18, Tom Eugelink wrote:

On 22-3-2015 13:53, John Hendrikx wrote:
On 22/03/2015 09:59, Tom Eugelink wrote:
On 22-3-2015 00:12, John Hendrikx wrote:

What I do need however is a way to restore the control to the exact same state it was in before (the same amount of pixels scrolled, the same item at the top, the same item at the bottom).

That is an interesting use case. Can you describe it a bit more?

Tom

My app works more like a browser, so when I "go back", I expect the same screen layout again (even though I have to reconstruct the screen again). With a ListView, this cannot be done as the #scrollTo method only shows an item. It doesn't remember however if that item was somewhere in the middle, top or bottom. It's just convenient if it was in the same spot, as the user might expect it there. Just like I expect my browser to go back to the same spot helps me a bit (eg: I clicked the link at the bottom of the screen somewhere, and there was something else interesting to the left of it -- that fails if it is now somewhere else).


Ah, ok. So I am curious; even though the browser main scrollbar might return to the position you were before (or even when refreshing a site might do), will it also return divs-with-scrollbar to the same position? I doubt it.

But HTML is much more low level than JavaFX's controls; if you were to build a JavaFX screen just using primitive controls, so create your own list with a pane and a scrollbar, then that scrollbar's API is available and you can do what you want. As soon as you start encapsulating things, then it becomes more interesting. Does for example JSF's list control allow you to specify the scroll position, or JQuery tables?

Okay, in what way does that change the fact that I'd like to show the user a screen that was how he left it? I could keep the entire page in memory I suppose, but I'd even like it to be the same between restarts (when navigating to the same part of the system again). Anyway, it's super easy to do, the List just has to expose the scroll position in pixels, and allow me to put it back there -- exactly how I solved it with a custom control.

--John

Reply via email to