<h1>Web Application Starter Project</h1>
<table align="center">
<tr>
<td colspan="2" style="font-weight:bold;">Please enter your name:</td>
</tr>
<tr>
<td id="nameFieldContainer"></td>
<td id="sendButtonContainer"></td>
</tr>
<tr>
<td colspan="2" style="color:red;" id="errorLabelContainer"></td>
</tr>
<tr>
<td id="readTextField"></td>
<td id="readTextButton"></td>
</tr>
<tr>
<td id="writeTextField"></td>
<td id="writeTextButton"></td>
</tr>
</table>
TextBox readText = new TextBox();
readText.setText("readText");
Button readTextButton = new Button("readText");
TextBox writeText = new TextBox();
writeText.setText("writeText");
Button writeTextButton = new Button("writeText");
RootPanel.get("readTextField").add(readText);
RootPanel.get("readTextButton").add(readTextButton);
RootPanel.get("writeTextField").add(writeText);
RootPanel.get("writeTextButton").add(writeTextButton);
readTextButton.addClickHandler(new ClickHandler()
{
public void onClick(ClickEvent event)
{
readText();
}
});
writeTextButton.addClickHandler(new ClickHandler()
{
public void onClick(ClickEvent event)
{
writeText(writeText.getText());
}
});
public native void readText()
/*-{
try
{
if (navigator.clipboard)
{
console.log('navigator.clipboard.readText()');
console.log('document.hasFocus()='+document.hasFocus());
console.log('$doc.hasFocus()='+$doc.hasFocus());
var promise = navigator.clipboard.readText();
var resolve = function(text) {
console.log(text);
};
var reject = function(reason) {
console.log('navigator.clipboard.readText failed: '+reason);
};
promise["catch"](reject);
promise.then(resolve,reject)["catch"](reject);
}
else
{
console.log('This browser does not support navigator.clipboard.');
}
}
catch (e)
{
console.error(e,e.stack);
}
}-*/;
public native void writeText(String p_text)
/*-{
try
{
var _this = this;
if (navigator.clipboard)
{
console.log('navigator.clipboard.writeText()');
console.log('document.hasFocus()='+document.hasFocus());
console.log('$doc.hasFocus()='+$doc.hasFocus());
var promise = navigator.clipboard.writeText(p_text);
var resolve = function(text) {
console.log('navigator.clipboard.writeText '+text);
};
var reject = function(reason) {
console.log('navigator.clipboard.writeText failed: '+reason);
};
promise["catch"](reject);
promise.then(resolve,reject)["catch"](reject);
}
else
{
console.log('This browser does not support navigator.clipboard.');
}
}
catch (e)
{
console.error(e,e.stack);
}
}-*/;
navigator.clipboard.readText()
document.hasFocus()=false
$doc.hasFocus()=true
navigator.clipboard.readText failed: NotAllowedError: Document is not focused.
navigator.clipboard.writeText()
document.hasFocus()=false
$doc.hasFocus()=true
navigator.clipboard.writeText failed: NotAllowedError: Document is not focused.
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-web-toolkit/5bda8f2f-bd40-4e8b-ba0f-9d445cae3000%40googlegroups.com.
No comments:
Post a Comment