-
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
The positionCaret does not work #293
Comments
Hi, can you please provide a simple self-contained example (single Java file) that demonstrates the problem? Also, what RichTextFX version are you using? |
Yes, The project (Zest-Writer) is Open-Source. Here is a commit with the problem: https://github.com/WinXaito/zest-writer/blob/b9b34479aa5a15481bbb7060831b305582db593a/src/main/java/com/zestedesavoir/zestwriter/view/MdConvertController.java#L106 (When I click on the "Bold" button, I gives focus to the editor and I would like to position the cursor before 2 position (Here I put 0 for example). Thanks ! |
He's using the |
And it's a problem ? I see that this is the last release https://github.com/TomasMikula/RichTextFX/releases |
A self-contained example is one that can be run without any dependencies. A simple example is one that is minimal such that it still demonstrates the issue. See SSCCE. This really is to increase your chance to get a helpful answer more quickly. |
I compiled their code. The issue is that they don't call In their code, when the user clicks a button (Bold, Italic), they want to style the selected text. However, upon clicking that button, the area no longer has the focus. Since the |
Thanks for investigating. That doesn't really correspond with this description, though:
@WinXaito does calling |
Turns out I had the wrong commit checked out. I'm looking into the one they've referenced. |
Ah... I see what's going on now. Let's say the area has the following text:
I select "here" and click the bold button. The caret is repositioned at 0. Now the text and caret appear as below:
As soon as I start typing anything (the area at this point has the focus), the caret will jump to the end of "here". Let's say I wrote "duck", the area would appear as follows:
|
When you start typing again, is "here" still selected? That would explain it, and using |
"here" is not still selected. |
I think |
We might want to look into that. There might be other methods that are public but which no longer need to be. Also, I've been curious about something else: why are some of the area's methods "hidden" in interfaces? For example, So, is this simply a way to group related methods together to make it easier to find them in the javadoc? |
There are some "core" methods, and then there are "derived" methods that can be implemented on top of the core methods. I wanted to implement the derived methods "somewhere else", so that I'm not sure it helps Javadoc. Regardless, it may become handy to have an interface with all the editing methods that is not a subclass of |
@WinXaito Can you confirm that using |
I was testing right now, I'll let you know! |
Yes, it works perfectly! Thank you very much. |
The strengths of the current approach is that all methods relating to the same topic (say navigation) are in the same file/interface. However, it also makes it somewhat tedious to follow the trail of all these methods in the source code (I don't think it's as bad for the javadoc...). /**
<h1>Navigation Methods</h1>
<ul>
<li>{@link #moveTo(int position)}</li>
<li>{@link #someOtherNavMethod(Object args)}</li>
</ul> However, this breaks the principle of self-documenting code, which the current approach seems to uphold better than this new approach. On another topic, I must admit that I've been using |
Let's deprecate I would refrain from reorganizing the interfaces for now, until it is clear to us what a better organization would be. |
Both ideas sound good to me. |
Hello,
I try to move my cursor in my
StyleClassedTextArea
with the functionSourceText.positionCaret(0);
, I see the cursor move, but when I write, it resumes where it was before the shifting.How can I fix this?
Thanking you
(Translated with Google translation)
Original:
Bonjour,
j'essaye de déplacer mon curseur dans mon
StyleClassedTextArea
, avec la functionSourceText.positionCaret(0);
, je vois bien le curseur se déplacer, mais dès que j'écris, il reprend la où il était avant le déplacement.Comment puis-je régler ce problème ?
En vous remerciant
The text was updated successfully, but these errors were encountered: