|
|
|
|
|
Re: Clipboard issue in RAP environment [message #1857947 is a reply to message #1857940] |
Wed, 08 March 2023 00:58 |
Kunok Joung Messages: 7 Registered: February 2023 |
Junior Member |
|
|
I wrote a sample program to reproduce this problem.
The mail template plugin of the RAP sample has been slightly modified and works as follows.
This is a simple sample that saves the entered sentence to the clipboard when you enter a sentence in the text field and click the "Copy" button.
If you test with the URL below on the device where the server is running, it works perfectly.
http://localhost:Port/mail
but,
If you test by accessing the URL below from another device, an error occurs.
http://IP:Port/mail
Am I just not sure how to use it properly?
I hope so. ^^
Here's the code that implements clipboard handling:
public class ViewComposite extends Composite {
private Text text;
/**
* Create the composite.
*
* @param parent
* @param style
*/
public ViewComposite(Composite parent, int style) {
super(parent, style);
setLayout(new GridLayout(3, false));
Label lblText = new Label(this, SWT.NONE);
lblText.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
lblText.setText("Text: ");
text = new Text(this, SWT.BORDER);
text.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
Button btnCopy = new Button(this, SWT.NONE);
btnCopy.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
String str = text.getText();
System.out.println("Text:" + str);
Clipboard clipboard = new Clipboard(getDisplay());
clipboard.setContents(new Object[] { str }, new Transfer[] { TextTransfer.getInstance() });
}
});
btnCopy.setText("Copy");
}
@Override
protected void checkSubclass() {
// Disable the check that prevents subclassing of SWT components
}
}
-
Attachment: ClipboardTest.zip
(Size: 30.81KB, Downloaded 47 times) -
Attachment: OK.png
(Size: 26.79KB, Downloaded 231 times)
[Updated on: Wed, 08 March 2023 01:03] Report message to a moderator
|
|
|
|
Re: Clipboard issue in RAP environment [message #1857975 is a reply to message #1857970] |
Thu, 09 March 2023 06:13 |
Kunok Joung Messages: 7 Registered: February 2023 |
Junior Member |
|
|
Unfortunately, even though I corrected it as instructed, the problem remains.
public ViewComposite(Composite parent, int style) {
super(parent, style);
setLayout(new GridLayout(3, false));
Label lblText = new Label(this, SWT.NONE);
lblText.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
lblText.setText("Text: ");
text = new Text(this, SWT.BORDER);
text.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
Button btnCopy = new Button(this, SWT.NONE);
btnCopy.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
String str = text.getText();
System.out.println("Text:" + str);
Clipboard clipboard = new Clipboard(Display.getCurrent());
clipboard.setContents(new Object[] { str }, new Transfer[] { TextTransfer.getInstance() });
clipboard.dispose();
}
});
btnCopy.setText("Copy");
}
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03713 seconds