Focus handling on custom controls

Werner Lehmann lehmann at media-interactive.de
Wed Nov 20 04:40:12 PST 2013


Hi,

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:

http://i.imgur.com/naPzK1W.png

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.

Rgds
Werner


More information about the openjfx-dev mailing list