Reputation: 24067
I'm using SWT Text component. Do someone know how can I handle copy/paste operation and modify data when copying to the buffer and when copying from the buffer? I don't want just handle Ctrl-C Ctrl-V because there are a lot of other keys to do that thing (Shift-Del/Shift-Insert) and even user can override these keys.
Thanks
Upvotes: 3
Views: 2980
Reputation: 4850
Create your own text component based on Text or StyledText and override copy() and paste(). This can do what you want.
Don't forget to override checkSubclass method.
Upvotes: 4
Reputation: 24788
The package you should look at is: import org.eclipse.swt.dnd.*
Simple example:
Clipboard clipboard = new Clipboard(parent.getDisplay());
String data = sb.toString();
clipboard.setContents(new Object[] { data }, new Transfer[] { TextTransfer.getInstance() });
clipboard.dispose();
Upvotes: -1