Java Version: jdk1.8.0_112
RichTextFX Version: richtextfx-fat-0.6.10.jar
I am using :
```
InlineCssTextArea textArea = new InlineCssTextArea();
textArea.setEditable(false);
textArea.setFocusTraversable(false);
and i am trying to scroll programmatically at the bottom :
```
//It returns the maximum length of the InlineCssTextArea `text`
System.out.println(textArea.getText().length());
System.out.println(textArea.getCaretPosition());
//It doesn't scroll to the end
textArea.positionCaret(textArea.getText().length());
The problem is that the length of InlineCssTextAreatext is 830 even if the caret is positioned at 830 it doesn't scroll to the bottom...

Is it a bug?
Are you using positionCaret intentionally? The right way to move the caret is via moveTo (I don't know if that will fix your problem).
Hello Jordan Martinez , thanks for fast reply .
I have tried your recommendation with different ways but again that Vertical scroll bar position doesn't seem to move down . Is there any other solution?
Best Regards.
@goxr3plus Can you provide a simple Application that reproduces the bug? I could probably help troubleshoot what's going on later on today as I'm not as familiar with the 0.6.10 release since it was released so long ago.
@JordanMartinez
Below is a simple working example showing the problem . I had run it on Window 10:
I will be very glad to download the newer version of RichTextFX but the links seem to be dead ( https://github.com/TomasMikula/RichTextFX/releases/download/0.7-M3/richtextfx-0.7-M3.jar ) , or those who working are giving as option the version 0.6.10 . The link for the newer repositories will be gold :) .
import java.util.Arrays;
import org.fxmisc.richtext.InlineCssTextArea;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.Priority;
import javafx.stage.Stage;
/**
* @author Alexander
*
*/
public class Tester extends Application {
@Override
public void start(Stage primaryStage) throws Exception {
primaryStage.setTitle("Testing InlineCssTextArea Vertical ScrollBar");
// --------------------------------------------------
InlineCssTextArea textArea = new InlineCssTextArea();
textArea.setEditable(false);
textArea.setFocusTraversable(false);
textArea.setMinSize(500, 200);
// textArea.setWrapText(true)
// -------root
GridPane root = new GridPane();
root.add(textArea, 0, 0);
// Append some text to the textArea
for (int i = 0; i < 200; i++)
textArea.appendText("I is : " + i + "\n");
// Below I am trying to move the Vertical ScrollBar to the Bottom
// Here it seems to be some kind of bug :) ?
textArea.moveTo(textArea.getText().length());
// or
textArea.positionCaret(textArea.getText().length());
// -------------------------------------------------
// Scene
Scene scene = new Scene(root, 500, 200);
primaryStage.setScene(scene);
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}
The first link is the correct link. The second one is the dead link. Looks like you missed a "v"
https://github.com/TomasMikula/RichTextFX/releases/download/v0.7-M3/richtextfx-0.7-M3.jar
https://github.com/TomasMikula/RichTextFX/releases/download/0.7-M3/richtextfx-0.7-M3.jar
Or was the deadlink on the ReadMe ?
I'm pretty sure your code should work, so I'm not sure what's causing the bug. I can reproduce it on my end on Linux.
In the 0.7-M3 release, you'll use the code:
java
area.moveTo(area.getLength());
area.requestFollowCaret();
Thanks for quick reply , i have updated to 0.7-M3 release and created the Tester class a little bit modified as you recommended. The problem got from 1 to 2:
1)No scroll bars by default on the InlineCSSTextArea (Tried to solve with ScrollPanebut it doesn't synchronize with the InlineCSSTextAreascrolling)
2)Using:
area.moveTo(area.getLength());
area.requestFollowCaret();
moves the caret to the correct position but the scroll pane isn't even scrolling....
Extra 馃槂 :
The setStyle(from,to,style) was working with 0.6.10 but now is selecting all the text from InlineCSSTextArea (maybe the specification of the method changed?)
The code (with all different tries):
import org.fxmisc.richtext.InlineCssTextArea;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.Priority;
import javafx.stage.Stage;
/**
* @author Alexander
*
*/
public class Tester extends Application {
@Override
public void start(Stage primaryStage) throws Exception {
primaryStage.setTitle("Testing InlineCssTextArea Vertical ScrollBar");
// --------------------------------------------------
InlineCssTextArea textArea = new InlineCssTextArea();
textArea.setEditable(false);
textArea.setFocusTraversable(false);
textArea.setMinSize(500, 200);
// textArea.setWrapText(true)
textArea.setMaxWidth(Double.MAX_VALUE);
textArea.setMaxHeight(Double.MAX_VALUE);
GridPane.setVgrow(textArea, Priority.ALWAYS);
GridPane.setHgrow(textArea, Priority.ALWAYS);
// -------root
GridPane root = new GridPane();
root.setMaxWidth(Double.MAX_VALUE);
root.setMaxHeight(Double.MAX_VALUE);
root.add(textArea, 0, 0);
// Append some text to the textArea
for (int i = 0; i < 200; i++)
textArea.appendText("I is [" + i
+ "] some text some text some text some textsome text some text text some text text some text text some text text some text text some text text some text\n");
// Below I am trying to move the Vertical ScrollBar to the Bottom
textArea.moveTo(textArea.getLength());
textArea.requestFollowCaret();
// -------------------------------------------------
// Scene
Scene scene = new Scene(root, 500, 200);
// Although it shows a scroll Pane it is not synchronized with textArea
// for example scrolling down on the text area doesn't appear on the
// ScrollPane
// Scene scene = new Scene(new ScrollPane(root), 500, 200);
// or
// Scene scene = new Scene(new ScrollPane(textArea), 500, 200);
// Show Stage
primaryStage.setScene(scene);
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}
1)No scroll bars by default on the InlineCSSTextArea (Tried to solve with ScrollPanebut it doesn't synchronize with the InlineCSSTextAreascrolling)
Ah! Sorry! We decoupled the scroll pane from the area in one of the releases before that one. Now you need to wrap it in a VirtualizedScrollPane:
````java
InlineCssTextArea area = // creation code;
VirtualizedScrollPane
GridPane root = new GridPane();
root.add(vsPane, 0, 0);
````
Try this code. I noticed that when wrapText is false, the virtualflow will scroll to the second-to-last line. I'm not entirely sure why that occurs, but it might be due to that line having no content on it. Regardless, when wrapText is true, it works as expected. (I also made the area editable and request focus after the stage is shown, so one can see the position of the caret).
````java
import org.fxmisc.flowless.VirtualizedScrollPane;
import org.fxmisc.richtext.InlineCssTextArea;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.Priority;
import javafx.stage.Stage;
/**
@Override
public void start(Stage primaryStage) throws Exception {
primaryStage.setTitle("Testing InlineCssTextArea Vertical ScrollBar");
// --------------------------------------------------
InlineCssTextArea textArea = new InlineCssTextArea();
// textArea.setEditable(false);
textArea.setFocusTraversable(false);
textArea.setMinSize(500, 200);
// textArea.setWrapText(true);
VirtualizedScrollPane<InlineCssTextArea> vsPane = new VirtualizedScrollPane<>(textArea);
vsPane.setMaxWidth(Double.MAX_VALUE);
vsPane.setMaxHeight(Double.MAX_VALUE);
GridPane.setVgrow(vsPane, Priority.ALWAYS);
GridPane.setHgrow(vsPane, Priority.ALWAYS);
// -------root
GridPane root = new GridPane();
root.setMaxWidth(Double.MAX_VALUE);
root.setMaxHeight(Double.MAX_VALUE);
root.add(vsPane, 0, 0);
// Append some text to the textArea
for (int i = 0; i < 200; i++)
textArea.appendText("I is [" + i
+ "] some text some text some text some textsome text some text text some text text some text text some text text some text text some text text some text\n");
// Below I am trying to move the Vertical ScrollBar to the Bottom
textArea.moveTo(textArea.getLength());
textArea.requestFollowCaret();
// -------------------------------------------------
// Scene
Scene scene = new Scene(root, 500, 200);
// Show Stage
primaryStage.setScene(scene);
primaryStage.show();
// focus area so can see the caret
textArea.requestFocus();
}
public static void main(String[] args) {
launch(args);
}
}
````
Also, I exposed more API in #418 that can accomplish what you desire with show-related methods. For example:
java
InlineCssTextArea area = // creation code;
area.showParagraphAtBottom(area.getParagraphs().size() - 1);
However, we haven't made a new release with that code yet.
Well done , thank you very much!! I also fixed the problem with the inline styles not working :) 馃憤
So the issue is maybe done .... :)
@goxr3plus What's your issue now?
Eveything is working perfect no issues :) . Thanks for help.