Focus handling on custom controls
swpalmer at gmail.com
Wed Nov 20 04:57:24 PST 2013
I did this by putting a TextField and a button in a region, and positioning the button manually in the layout method to be just inside the right edge of the TextField. Simple manipulation of the TextField's insets in the CSS prevents the text from going under the button. I set the button so that it isn't focusable. It isn't a proper "skin", but it works for my purposes.
> On Nov 20, 2013, at 7:40 AM, Werner Lehmann <lehmann at media-interactive.de> wrote:
> I made a custom control and am trying to get the focus handling right. This is a textfield with some buttons on the right hand side, e.g. an ellipsis button:
> The control skin basically is an hbox with a textfield and a few stackpanes as its children. The question is now how can I have this control focused while user input goes into the embedded textfield?
> I worked around this by removing focus style from the textfield and styling the outer control as focused when the textfield actually has the focus - that's a bit faked, of course since the actual focus owner is still the embedded textfield. Maybe input events need to be captured on the outer control and rerouted to the textfield? How would I adjust source/target on the events then?
> BTW, this is on FX2 so I don't have layoutChildren(x,y,w,h) - but the question would apply to other custom control types, too.
More information about the openjfx-dev