The trouble with Skins
tomas.mikula at gmail.com
Tue Mar 24 23:23:21 UTC 2015
On Tue, Mar 24, 2015 at 6:47 PM, Tom Eugelink <tbee at tbee.org> 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).
> I was thinking; maybe you are approaching this from the wrong angle by
> trying to break open the controls. How about inspecting the node tree, after
> it has been constructed (all skins have created their nodes)? After all, a
> ListView will insert a scrollpane into the tree, which will insert a
> scrollbar. You could analyze the resulting node tree and search for the
> scrollbars, then record their scroll values.
> The trick would be to identify the correct one again to reset the value. You
> may be able to derrive an identifier from the tree path to the scrollbar,
> assuming it would be identical before and after. Or maybe better, you could
> place a UUID in the node's properties and also use that UUID for storing the
> recorded values. Could that work?
I'm sure you could make it work this way, but 1) it is a lot of work
and 2) it is very fragile. It will break when ListView internals
change or when the ListView is loaded with a different skin on
restart. So it's a matter of how badly John wants this done.
Btw, "inspecting the node tree" seems like "break open the controls" to me.
I think it is OK to say that ListView does not support this; my more
general question was how should one proceed when writing a custom
control that supports some view-specific details and at the same time
wants to have customizable (i.e. skinnable) look & feel.
More information about the openjfx-dev