-
Notifications
You must be signed in to change notification settings - Fork 237
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
StyledTextArea scrolls to the caret every time span style is changed #101
Comments
This is happening because the area automatically scrolls to the current caret position every time there is an edit (e.g. style set). I could fix this by only scrolling to the caret when the edit is made by user interaction (e.g. typing text). But this could break the behavior for other users that expect the automatic scroll to the caret. Currently, there is no viable workaround for them—it is currently not possible to explicitly request to scroll to the caret. You could probably work around this by calling |
@TomasMikula could you describe how one might work around the problem in more detail? In my application, I am calling Perhaps this could be fixed by adding a configuration flag to the textarea that enables or disables automatic scrolling to the caret? |
This can now actually be fixed by providing a method like It was previously not possible to implement |
@TomasMikula I'd like to implement this method. Can you tell me exactly where in the code the invocation occurs to scroll to the caret when there is an edit? |
@lantunes great! There already is a method
|
@TomasMikula I am happy to see this is being picked up. My project ended up being abandoned, so I did not get back to this, but it is good to hear that this is a possibility. Thanks for the help! |
@TomasMikula for this issue and in light of #375, should the referenced code's subscription code still be deleted? Or just changed to |
Now that we have access to view, I would do the popup positioning differently. It actually doesn't need special support from StyledTextArea, we just need to expose a property that reflects current caret position on screen. User code can do the rest. Storing a popup window and positioning properties inside StyledTextArea was weird, but was necessary so that skin could pick it up and position it during its own layout. All of that is a separate issue from this one. |
So an |
It might be something else than |
Not sure what you mean by "base Popup class", but we already have a PopupDemo. |
Meaning a class that already has |
I forgot that sometimes the position of the anchor can change as well (is it in relation to the caret? Or the end of the selection?) Yeah, |
I have a StyleClassedTextArea and load a String into it. I have a button event which calls setStyleClass a number of times using data external to the document. For some reason, when I call it, the text area always automatically scrolls to the bottom of the document. I have tried all kinds of variations, but it happens. Also, when I make the setStyleClass dependent on the document's content changing and I edit the text in the middle of the text field, it scroll-jumps into a position where the line I am editing becomes the bottom-most line in the view. What am I doing wrong?
Thanks,
Matthias
Minimal Code Example (just paste a lot of text into the field and click the button and provide some stylesheet in the css file defining a 'red' style):
The text was updated successfully, but these errors were encountered: