Search in sources :

Example 1 with CaretNode

use of org.fxmisc.richtext.CaretNode in project RichTextFX by FXMisc.

the class MultipleCaretSelectionTests method adding_caret_works.

@Test
public void adding_caret_works() {
    CaretNode caret = new CaretNode("test caret", area, 0);
    interact(() -> assertTrue(area.addCaret(caret)));
    assertTrue(caret.getCaretBounds().isPresent());
    assertEquals(0, caret.getPosition());
}
Also used : CaretNode(org.fxmisc.richtext.CaretNode) InlineCssTextAreaAppTest(org.fxmisc.richtext.InlineCssTextAreaAppTest) Test(org.junit.Test)

Example 2 with CaretNode

use of org.fxmisc.richtext.CaretNode in project RichTextFX by FXMisc.

the class MultipleCaretSelectionTests method attempting_to_add_caret_associated_with_different_area_fails.

@Test
public void attempting_to_add_caret_associated_with_different_area_fails() {
    InlineCssTextArea area2 = new InlineCssTextArea();
    CaretNode caret = new CaretNode("test caret", area2);
    interact(() -> {
        try {
            area.addCaret(caret);
            fail();
        } catch (IllegalArgumentException e) {
        // cannot add a caret associated with a different area
        }
    });
}
Also used : CaretNode(org.fxmisc.richtext.CaretNode) InlineCssTextArea(org.fxmisc.richtext.InlineCssTextArea) InlineCssTextAreaAppTest(org.fxmisc.richtext.InlineCssTextAreaAppTest) Test(org.junit.Test)

Example 3 with CaretNode

use of org.fxmisc.richtext.CaretNode in project RichTextFX by FXMisc.

the class MultipleCaretSelectionTests method removing_caret_works.

@Test
public void removing_caret_works() {
    CaretNode caret = new CaretNode("test caret", area, 0);
    interact(() -> {
        assertTrue(area.addCaret(caret));
        assertTrue(area.removeCaret(caret));
    });
}
Also used : CaretNode(org.fxmisc.richtext.CaretNode) InlineCssTextAreaAppTest(org.fxmisc.richtext.InlineCssTextAreaAppTest) Test(org.junit.Test)

Example 4 with CaretNode

use of org.fxmisc.richtext.CaretNode in project RichTextFX by FXMisc.

the class MultiCaretAndSelectionDemo method addExtraCaret.

private void addExtraCaret() {
    CaretNode extraCaret = new CaretNode("another caret", area);
    if (!area.addCaret(extraCaret)) {
        throw new IllegalStateException("caret was not added to area");
    }
    extraCaret.moveTo(3, 8);
    // since the CSS properties are re-set when it applies the CSS from files
    // remove the style class so that properties set below are not overridden by CSS
    extraCaret.getStyleClass().remove("caret");
    extraCaret.setStrokeWidth(10.0);
    extraCaret.setStroke(Color.BROWN);
    extraCaret.setBlinkRate(Duration.millis(200));
}
Also used : CaretNode(org.fxmisc.richtext.CaretNode)

Example 5 with CaretNode

use of org.fxmisc.richtext.CaretNode in project RichTextFX by FXMisc.

the class MultipleCaretSelectionTests method modifying_caret_before_adding_to_area_does_not_throw_exception.

@Test
public void modifying_caret_before_adding_to_area_does_not_throw_exception() {
    CaretNode caret = new CaretNode("test caret", area);
    interact(() -> {
        caret.moveToAreaEnd();
        area.addCaret(caret);
        caret.moveToParEnd();
        area.removeCaret(caret);
        caret.moveToParStart();
        area.addCaret(caret);
        area.removeCaret(caret);
    });
}
Also used : CaretNode(org.fxmisc.richtext.CaretNode) InlineCssTextAreaAppTest(org.fxmisc.richtext.InlineCssTextAreaAppTest) Test(org.junit.Test)

Aggregations

CaretNode (org.fxmisc.richtext.CaretNode)5 InlineCssTextAreaAppTest (org.fxmisc.richtext.InlineCssTextAreaAppTest)4 Test (org.junit.Test)4 InlineCssTextArea (org.fxmisc.richtext.InlineCssTextArea)1