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
Style At Caret Vs that of Insert(StyledDocument). #46
Comments
(update: cleaned up comments) I apply a style to a range. Range is is defined by adding white space when needed ( if the caret happens to be at the end) or by coloring the character before the caret. (not the best behavior I admit).
Because this does not utilize the subscribe to change method, I can append styled documents and have them come in with their styles. The problem with it is that it is not as clean. Would it be possible to add a method that will unsubscribe, or override caret style, append styled document, then revert caret style. Not sure what the best behavior is. What do you suggest? :/ |
Hi Maher,
Subscription sub = area.plainTextChanges().subscribe(...);
// when no longer interested in changes
sub.unsubscribe(); To ignore changes temporarily, you can do this InterceptableEventStream<PlainTextChange> changes =
richTextArea.plainTextChanges().interceptable();
changes.subscribe(change -> {
// handle the change
});
// ignore changes while inserting styled document
changes.muteWhile(() -> {
richTextArea.insert(index, document);
}); or this Indicator ignoreChanges = new Indicator();
richTextArea.plainTextChanges().subscribe(change -> {
if(ignoreChanges.isOff()) {
// handle the change
}
});
// ignore changes while inserting styled document
ignoreChanges.onWhile(() -> {
richTextArea.insert(index, document);
}); |
Thanks! On Tue, Apr 22, 2014 at 7:11 PM, TomasMikula notifications@github.comwrote:
|
I tried the : InterceptableEventStream changes = changes.subscribe(change -> { it worked, but the unsubscribe didn't. I can;t seem to unsubscribe. The process is this: I create a view port, which as a text area, and declare subscription Also a bunch of styling buttons are created. When style parameter button is pressed. the subscription object gets So it happens the first time, and continues to be reset again, every time a
= editor.richTextArea.plainTextChanges().subscribe(change -> { and when I want to insert a styled document, I do this
editor.richTextArea.insert(editor.richTextArea.getCaretPosition(), do you see anything incorrect in the process? On Tue, Apr 22, 2014 at 7:14 PM, Maher Elkhaldi m.s.khaldi@gmail.comwrote:
|
on a second thought i think I know why. I am inserting at the end of a document. so if my guess is correct, when Is my guess correct? On Tue, Apr 22, 2014 at 8:32 PM, Maher Elkhaldi m.s.khaldi@gmail.comwrote:
|
Calling You shouldn't call |
Hi Tomas,
I have the following scenario:
I create a text, style it, then save it to a clip board as a styled document.
Then i apply a different style at the caret. using:
After this step, if I try to insert the styledDocument that I saved previously, it will come in using the last style applied at the caret, not its own style. So this is similar to inserting plain text.
I guess this is as expected, since the text area is subscribing to change, and any change will take in the style last applied.
I tried to do something like
but with no luck. I also tried to set the subscribe to null.. but I gt an error.
is there a way to override that subscription or stop it in the event when i am inserting a styled document?
The text was updated successfully, but these errors were encountered: