Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » How to activate HW button on Browser
How to activate HW button on Browser [message #460241] Tue, 23 August 2005 09:19 Go to next message
WooChul Jung is currently offline WooChul JungFriend
Messages: 2
Registered: July 2009
Junior Member
Hello,
I am novice about the SWT-Browser, so this my question can be trivial.
But if anybody know how to solve this my problem, please let me know that.

My question is like below.
I want to activate HW button on Browser, but it seems not.
Below thing is the source code. ( SWT version - 3138 on windows)
The step to do is
1) Executes HWButtonBrowser.
2) Click any point on the Browser window
3) Press any keyboard button
In this case, any thing doesn't print on the console.

import org.eclipse.swt.*;
import org.eclipse.swt.widgets.*;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.browser.*;
import org.eclipse.swt.events.FocusEvent;
import org.eclipse.swt.events.FocusListener;
import org.eclipse.swt.events.KeyEvent;
import org.eclipse.swt.events.KeyListener;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.MouseListener;
public class HWButtonBrowser {
public static void main(String[] args) {
Display display = new Display();
Shell shell = new Shell(display);
shell.setText("PRBrowser");
shell.setLayout(new FillLayout());
shell.addKeyListener(new KeyListener() {
public void keyPressed(KeyEvent arg0) {
System.out.println("keyPressed : " + arg0.toString());
}
public void keyReleased(KeyEvent arg0) {
System.out.println("keyReleased : " + arg0.toString());
}
});

Browser browser = new Browser(shell, SWT.NONE);
browser.setUrl("http://www.eclipse.org");

shell.open();

while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
}
}
Re: How to activate HW button on Browser [message #460267 is a reply to message #460241] Tue, 23 August 2005 14:39 Go to previous message
Grant Gayed is currently offline Grant GayedFriend
Messages: 2150
Registered: July 2009
Senior Member
You should hook your key listener on the Browser, not on the Shell.

Grant

"WooChul Jung" <wcjung@kr.ibm.com> wrote in message
news:fef7b9c79dee699199b2895efc6755fa$1@www.eclipse.org...
> Hello,
> I am novice about the SWT-Browser, so this my question can be trivial.
> But if anybody know how to solve this my problem, please let me know that.
>
> My question is like below.
> I want to activate HW button on Browser, but it seems not.
> Below thing is the source code. ( SWT version - 3138 on windows)
> The step to do is
> 1) Executes HWButtonBrowser.
> 2) Click any point on the Browser window
> 3) Press any keyboard button
> In this case, any thing doesn't print on the console.
>
> import org.eclipse.swt.*;
> import org.eclipse.swt.widgets.*;
> import org.eclipse.swt.layout.*;
> import org.eclipse.swt.browser.*;
> import org.eclipse.swt.events.FocusEvent;
> import org.eclipse.swt.events.FocusListener;
> import org.eclipse.swt.events.KeyEvent;
> import org.eclipse.swt.events.KeyListener;
> import org.eclipse.swt.events.MouseEvent;
> import org.eclipse.swt.events.MouseListener;
> public class HWButtonBrowser {
> public static void main(String[] args) {
> Display display = new Display();
> Shell shell = new Shell(display);
> shell.setText("PRBrowser");
> shell.setLayout(new FillLayout());
> shell.addKeyListener(new KeyListener() {
> public void keyPressed(KeyEvent arg0) {
> System.out.println("keyPressed : " + arg0.toString());
> }
> public void keyReleased(KeyEvent arg0) {
> System.out.println("keyReleased : " + arg0.toString());
> }
> });
>
> Browser browser = new Browser(shell, SWT.NONE);
> browser.setUrl("http://www.eclipse.org");
>
> shell.open();
>
> while (!shell.isDisposed()) {
> if (!display.readAndDispatch())
> display.sleep();
> }
> }
> }
>
Previous Topic:Escaping characters in FormText
Next Topic:syncExec Question
Goto Forum:
  


Current Time: Tue May 11 23:21:25 GMT 2021

Powered by FUDForum. Page generated in 0.01937 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top