|
Re: SWT Browser loss its focus when Browser.evaluate() is called [message #513062 is a reply to message #512426] |
Mon, 08 February 2010 16:57 |
Grant Gayed Messages: 2150 Registered: July 2009 |
Senior Member |
|
|
Hi,
This should not happen, and I don't see it happen with the snippet below
(tried with IE6- and XULRunner-based Browsers on Windows 2000). If you run
the snippet and give focus to the page's text control does it lose focus
when the timer expires after 5s? And which platform and native browser are
you using?
public static void main(String [] args) {
Device.DEBUG = true;
final String html = "<html><title>Snippet</title><body><p id='myid'>Best
Friends</p><p id='myid2'>Cat and Dog</p><textarea rows=\"2\"
cols=\"20\">hi</textarea></body></html>";
final Display display = new Display();
final Shell shell = new Shell(display);
shell.setLayout(new GridLayout());
final Browser browser;
try {
browser = new Browser(shell, SWT.NONE);
} catch (SWTError e) {
System.out.println("Could not instantiate Browser: " +
e.getMessage());
display.dispose();
return;
}
browser.setLayoutData(new GridData(200,200));
browser.addProgressListener(new ProgressListener() {
public void changed(ProgressEvent event) {}
public void completed(ProgressEvent event) {
display.timerExec(5000, new Runnable() {
public void run() {
String value = (String)browser.evaluate("return
document.getElementById('myid').childNodes[0].nodeValue;");
System.out.println("Node value: "+value);
}
});
}
});
new Text(shell, SWT.SINGLE); // <--- I do nothing
browser.setText(html);
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) display.sleep();
}
display.dispose();
}
Grant
"Anakkapan K." <knock_kknd@hotmail.com> wrote in message
news:hkg7ud$2r1$1@build.eclipse.org...
> I open an editor, which is an html page, on SWT Browser. When I want to
get data from it, I use Browser.evaluate() to obtain the data from editor
using javaScript. But the editor then loss a focus every time I try to get
its data. Is it any way to solve this problem?
>
> PS. I tried evaluate other function on that editor page and it loss its
focus every time evalute() is called.
|
|
|
Powered by
FUDForum. Page generated in 0.02567 seconds