Hi Randahl, I think the general advice is to avoid subclassing controls if possible. You can create your custom control that embeds a text field and filter events on your custom control so they never reach the embedded text field.
Tomas On Fri, Jun 13, 2014 at 10:11 AM, Randahl Fink Isaksen <rand...@rockit.dk> wrote: > I have noticed that quite many developers are having trouble avoiding > triggering of focus navigation occurring when a user presses the UP and DOWN > arrow keys. From a number of different forum posts I have seen how people are > jumping through hoops to avoid this. > > I myself have the challenge, that I need to use the UP and DOWN keys for > changing the selected autocompletion in a text field, and it seems that no > matter how greedily I try to consume or filter out these KeyEvents, JavaFX > still insists on moving the focus from one field to the next. > > This got me thinking: Why is JavaFX keyboard event handling so rigid? If you > implement a control which listens for keyboard events on itself and does some > cool stuff, that is fine. But once you implement a subclass that wishes to > replace some of that behaviour you are in trouble, because once the > EventHandlers are registered, there is no public API to replace them. > > Is this a conscious design decision? Is it something that I should file a > feature request on, or have I overlooked a part of the API which could be > used here? > > Randahl >