focus property in composed control

Michael Heinrichs michael at netopyr.com
Mon Feb 23 08:33:38 UTC 2015


Hi Tom,

can you provide a code example? I am not sure I understand all the details correctly. :) In particular it is important to know which of the properties are defined in your code and which properties you are just using. For example it is possible to bind a readonly property, but only if it is defined in your code.

Cheers,
Michael


> On 23 Feb 2015, at 09:03, Tom Eugelink <tbee at tbee.org> wrote:
> 
> JFXtras has a number of extended textfields (BigDecimal, Calendar, LocalDate, ...). These controls use a TextField in their skin to compose this control. These extended textfield controls have a readonly focusProperty()... What would be the best way to forward the focusProperty of the TextField to the control's focusProperty?
> - Binding is not possible, because it is read only.
> - Setting the value in the skin is not possible, because it is read only.
> - setFocused method is protected final
> 
> What works is the following setup:
> - create a _public_ focusForwardProperty in the Skin
> - listen to the focusProperty of TextField and set the focusForwardProperty accordingly
> - listen to the skinProperty in the Control and when set, bind a listener to the focusForwardProperty
> - in this  listener call setFocused with the value of focusForwardProperty
> 
> This approach at least prevents the control's API to be polluted with public methods, but requires a property just for the sake of publishing the value. Ideally one would like to bind both focusProperties.
> 
> Tom



More information about the openjfx-dev mailing list