JDK-8090849 : Add possibility to get caret screen coordinates for TextArea/TextField and maybe future rich text control
  • Type: Enhancement
  • Component: javafx
  • Sub-Component: controls
  • Affected Version: 8
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • Submitted: 2013-05-06
  • Updated: 2018-09-05
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
tbdUnresolved
Description
I think this is necessary, for example if you want to give a suggestion popup to the user while writing in the text area. You want to display the popup at the current caret position, and so you need the screen coordinates to do so.

Regards,
subzero
Comments
The problem with getting screen coordinates of the caret is that they depend on the TextArea skin. For custom skins, TextArea would have no reliable way of getting the caret shape and its coordinates. In RichTextFX, I took a different approach, providing an ObjectProperty<PopupWindow> popupAtCaretProperty(); The user can set this to a popup window they want positioned next to the caret. The skin then takes care of positioning it. The user is still responsible for showing/hiding the popup. Here is a demo application https://github.com/TomasMikula/RichTextFX/blob/master/richtextfx-demos/src/main/java/org/fxmisc/richtext/demo/PopupDemo.java and here is a screenshot http://t.co/TAtxzuOytF
12-04-2014

I agree with James, this would be a pretty simple but effective solution, if there is no time for a more elaborate one. Regards, Aurelian
07-05-2013

This is related to OTN discussion https://forums.oracle.com/forums/thread.jspa?threadID=2532556&tstart=0 I think simply providing a style class or id for the caret path (and documenting it as "substructure" in the css documentation) would suffice, as this would allow access via textArea.lookup(...) and then getting the bounds of the result.
06-05-2013