0

After setting the global text color in my JavaFX application in CSS (*{ -fx-font-size: 9px; -fx-text-fill: #000000 } I've noticed that the caret in TextFields is 2px thick and a different color to the text (#787878).

Example of how caret is incorrect color

I have spent a few hours looking around and can't find any explanation as to why this is the case. There are a few answers on how you can change the caret color/size but these don't seem to work as caretPath isn't recognised (see here and here).

Oliver Dalton
  • 379
  • 2
  • 16
  • 1
    It seems like the caret is of by half a pixel resulting in 2 pixel columns with half transparency being rendered... – fabian Nov 07 '19 at 19:47
  • That sounds very likely, do you know how I could rectify this? – Oliver Dalton Nov 07 '19 at 20:41
  • 1
    This would require adjustment of the skin.However even though the skin is part of the public api.The part responsible for the cursor position is private though and therefore there's no chance of overriding this.The source code is accessible, so c&p could be an alternative,but the class refers to parts of the non-public api possibly creating copies of this class and any class in the private api it refers to could work,but I'm not sure how much code you'd need to duplicate.Applying a horizontal scale could reduce the effect,but then there could be issues when moving the cursor between chars – fabian Nov 07 '19 at 21:46
  • I will have a play around and see if I can figure out a way of doing it. If you or anyone else could suggest something as an answer that could work that would be very helpful. Thank you! – Oliver Dalton Nov 07 '19 at 21:56
  • I found [this](https://github.com/javafxports/openjdk-jfx/issues/265) on GitHub but unfortunately no solution. – Oliver Dalton Nov 07 '19 at 22:12
  • I managed to resolve this issue temporarily by editing the font file and increasing the size of the space by 25%. Unsure as to why this fix stopped working as nothing changed as far as I know. – Oliver Dalton Nov 19 '19 at 01:43

0 Answers0