-
Notifications
You must be signed in to change notification settings - Fork 236
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
Cut, Copy, Paste #55
Comments
T clarify, when I try to paste using the shortcut, it pastes, but whatever is being pasted comes in with the style at caret. The second issue, is that when I try to paste using a menuItem from a context menu, it gives this error. both use the same exact code. I just factored the code into separate method as below:
I run into the same NPE and sometimes things get pasted without the correct style, and some other times, the cutStyledDoc variables does nt get updated correctly. Any feedback on this would be great. |
Hi Maher, are you sure this.richTextArea.insert(this.richTextArea.getCaretPosition(), styledDocument); |
Hi Tomas, I am trying to verify that. The same code works on menu items well and not when using the shortcuts. I am writing a check on that as we speak. will report shortly. any ideas though on the insert with styling? |
HI, I added these checks to the CCP code:
///// Now it pastes, but it shows this error after.
The code where it breaks is: in:
|
for sure, the menu item action works better. would it be because of the keyevent gets triggered multiple times as the key is being pressed? |
What I meant was to add this check at the beginning of your if(styledDocument == null) {
throw new AssertionError("Trying to insert null");
} |
no errors. I'll do more inspection and report back. |
Hi, after extensive testing, i am convinced it has to do with key listening filter. I added a counter that would increase when pressing the combination, and it does go beyond 1. so what I do, is only copy/cut when it is 0 so I dont run into the null value for styledoc. and this counter gets reset to zero when the C or X keys are released. |
sorry for the false alarm. |
The only issue I have left is that pasting using the shortcut, does not come with the original styled Doc style. It comes with whatever the style at caret is. this is the method that inserts:
} This is the subscribe and unsubscribe methods.
When I trigger this method using the menu items, inserting the styled doc come in with its original style, but with the shortcut, it comes in based on the style assigned t caret. |
Sorry, I must have overlooked your last comment :( Whether your method is triggered by a menu item or a keyboard shortcut really shouldn't matter. Are you sure your Some further comments on your code:
|
Hi Tomas, Thanks for the feedback. I really appreciate your help. I changes the code as you advised, but I am getting the same thing. It is OK for now I guess. Hopefully once I get things done I will post That being said, I can market it as a cool feature though: inserting Best, On 30/05/2014 9:21 AM, TomasMikula wrote:
|
I didn't expect the changes I suggested to fix your problem, just to clean your code a little bit. Did you make sure that Is your key combination "Ctrl+V" or something else? |
Hi Tomas, yes it is CNTRL+V. and I did all the checking. it does call On 30/05/2014 12:18 PM, TomasMikula wrote:
|
So is this actually resolved as invalid? I'd like to see it closed so people don't investigate too much time considering this as a duplicate. |
Right. |
Hi Tomas, I am trying to implement a cut/copy/paste with styles. I ran into this errort:
The code I am using is this:
where
InsertStyleDoc is:
the subscription is being enabled and disabled to allow the insertion to come in with style, and not the style at caret, which is defined the subscription to change.
The text was updated successfully, but these errors were encountered: