×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: Java
Posted by: Ellirabeth Dzhurko
Added: Feb 2, 2017 7:38 AM
Views: 2266
Tags: no tags
  1. protected ObservableBooleanValue caretVisible;
  2.  
  3. /**
  4.          * The caret is visible when the text box is focused AND when the selection
  5.          * is empty. If the selection is non empty or the text box is not focused
  6.          * then we don't want to show the caret. Also, we show the caret while
  7.          * performing some operations such as most key strokes. In that case we
  8.          * simply toggle its opacity.
  9.          * <p>
  10.          */
  11.         caretVisible = new BooleanBinding() {
  12.             {
  13.                 bind((richTextArea.focusedProperty()), richTextArea.anchorProperty(), richTextArea.caretPositionProperty(),
  14.                         richTextArea.disabledProperty(), blink);
  15.             }
  16.  
  17.             @Override
  18.             protected boolean computeValue() {
  19.                 return !blink.get() && richTextArea.isFocused() && !richTextArea.isDisabled() && !isHideCaret() &&
  20.                         // RT-10682: On Windows, we show the caret during selection, but on others we hide it
  21.                         (isWindows() || richTextArea.getCaretPosition() == richTextArea.getAnchorPosition());
  22.             }
  23.         };