If setStyle doesn't work for graphic, then that is a bug.
I agree that css and user concurrency is black magic. Better
documentation would help, but I'm not yet convinced that there is an API
solution to the problem unless the API is up in *PropertyBase (e.g.
init(T value), void reset())
On 5/28/14, 4:46 PM, Tom Schindl wrote:
setStyle works for most but often not for graphic - i went the styleproperty
cast way but my gut tells me there's something we need improve the CSS vs User
concurrency is something very few people know about and the bad thing is the
API does not give you a clue about it.
Tom
Von meinem iPhone gesendet
Am 28.05.2014 um 21:19 schrieb David Grieve <david.gri...@oracle.com>:
Using styles is preferable to setting the property value. If styles are used,
then you don't have the problem you describe.
An alternative, if styles are not used, is to cast the property to
StyleableProperty and use applyStyle(null, value) instead of set. CSS then
thinks that the value has never been set. This pattern is used, for example, in
Labeled to initialize the focusTraversableProperty to false. So one option is
to use applyStyle in the updateItem method rather than set. Of course, this is
one of those tricks that you have to be in-the-know to make use of. But I would
argue that restoreInitialPropertyState() is also a trick that you have to be
in-the-know to make use of.
On 5/28/14, 6:35 AM, Tom Schindl wrote:
Hi,
All views in JavaFX are virtual and the Cell instances are reused but
this brings with it the problem that if you once modified a CSS
styleable value (e.g. the textfill, font, ...) you are unable to return
to a state where a CSS could be applied.
I think Cell needs to provide reset methods for properties who are
styleable so that one can set back the cell into a css-styleable state,
or maybe we want this to be more general and we need to provide a method
for all properties who are styled so that we can reset them?
I could imagine Node having a method: restoreInitialPropertyState()
which subclasses need to implement to restore all its properties to be
css styleable.
For Cell i think there's no way around that because it is reused and
needs to have a way to get back to the original state.
Tom