On character input, two events are fired: KEY_PRESSED and KEY_TYPED.
When my control is interested in the characters, KEY_TYPED should be
handled, because it contains the entered Unicode characters. In that
case, however, I would also like to consume the corresponding
KEY_PRESSED event, so that it does not bubble up the scene graph.

A user reported an instance of this problem with my RichTextFX control
placed inside a ScrollPane: when spacebar was pressed, a space was
inserted in the text area *and* the ScrollPane scrolled down. This
happened because RichTextFX handled the KEY_TYPED event, but let the
KEY_PRESSED bubble up and ScrollPane handled the KEY_PRESSED event.

I can fix the above case by RichTextFX consuming KEY_PRESSED events
whose key code isLetterKey(), isDigitKey() or isWhitespaceKey(), but
it is not a general solution: it would still not work if ScrollPane
used e.g. '[' and ']' to scroll up and down.

My question is, is there a general solution for this kind of problem?

Given a KEY_PRESSED event, being able to tell whether there is a
corresponding KEY_TYPED event generated would solve the problem, but
it is currently not possible AFAIK.

Regards,
Tomas

Reply via email to