Skip to content

Commit 14eca9b

Browse files
Make caret transparent to mouse picking (issue 124) (#1032)
If you install a mouse handler on a TextExt area using setOnMouseClicked(), there's a small chance that your mouse click will be ignored (this happens approximately one time in ten in my experience). The problem occurs when you click at the exact same position as the flashing caret while the caret is visible; this confuses the java FX mouse-picking algorithm, which causes the MouseEvent to be sent to the ParagraphText node rather than the TextExt. The fix is simply to make the caret transparent to mouse picking. See this link for more evidence + screenshots : #124
1 parent 17bdba2 commit 14eca9b

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

richtextfx/src/main/java/org/fxmisc/richtext/CaretNode.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ public CaretNode(String name, GenericStyledArea<?, ?, ?> area, SuspendableNo dep
143143

144144
this.getStyleClass().add("caret");
145145
this.setManaged(false);
146+
this.setMouseTransparent(true); // don't want the caret to be pickable, see iss 124
146147

147148
internalTextPosition = Var.newSimpleVar(startingPosition);
148149
position = internalTextPosition.suspendable();

0 commit comments

Comments
 (0)