Event when CSS is applied
Tom Eugelink
tbee at tbee.org
Tue Feb 17 15:14:15 UTC 2015
Registering to fontProperty works, but potentially requires a lot of listeners on every property that may affect the size, like effect, scale, etc. So I'm leaving it in layoutChildren for now; better once to many than not often enough.
Would adding such an event be a big change?
On 17-2-2015 14:50, David Grieve wrote:
>
> On 2/17/15 8:02 AM, Tom Eugelink wrote:
>> I have a skin (of a control) that centers a Text node. This Text node can be styled via CSS, so this styling is a factor when centering. because larger font means wider text.
>>
>> The centering works perfectly, the only problem is figuring out when to center the node. At the moment I'm centering the node on every layoutChildren call of the skin, but this is way to often, because after applying the CSS chances are very low that the node will need to be repositioned.
>>
>> Basically I would like to be informed when the styling of a node has been applied or changed. Is there some place that can provide this information?
>>
> Not in general, no. But you can add a listener to a property that is styled by CSS and react to the change. You might add a listener to the Text node's fontProperty, for example. Clearly this isn't an all-purpose solution. Another approach is to hold onto the bounds (or maybe just the pref width and height) of the child node. If the old bounds doesn't equal the new bounds, then recenter.
More information about the openjfx-dev
mailing list