Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Browser Widget and <Ctrl> N
Browser Widget and <Ctrl> N [message #451671] Fri, 04 March 2005 20:14 Go to next message
Kalman Hazins is currently offline Kalman HazinsFriend
Messages: 76
Registered: July 2009
Member
I am using Browser widget on Windows XP. When I click <CTRL> n - it opens up
a new window, which for some reason displays the contents of my C drive.

Is there a way to detect it and prevent this behavior?

I have tried using OpenWindowListener as well as KeyListener to no avail.

Thanx,
- Kalman
Re: Browser Widget and <Ctrl> N [message #451729 is a reply to message #451671] Mon, 07 March 2005 16:37 Go to previous messageGo to next message
Christophe Cornu is currently offline Christophe CornuFriend
Messages: 304
Registered: July 2009
Senior Member
Hi Kalman,

You can redirect <Ctrl>N by creating a MenuItem and using
MenuItem.setAccelerator(SWT.CONTROL | 'n'). This menu item will be invoked
instead of IE.

Chris
Re: Browser Widget and <Ctrl> N [message #451736 is a reply to message #451729] Mon, 07 March 2005 18:37 Go to previous messageGo to next message
Kalman Hazins is currently offline Kalman HazinsFriend
Messages: 76
Registered: July 2009
Member
If you have a pop up menu on the browser - the accelerator doesn't get
called, and a regular menu you got to have a shell (Decoration for). I need
to create a createBrowser() method that will give me back a Browser that
will ignore Control-N.

there's got to be a better way !!!

Veronika, any ideas?



"Christophe Cornu" <christophe_cornu@ca.ibm.com> wrote in message
news:d0i00k$bmm$1@www.eclipse.org...
> Hi Kalman,
>
> You can redirect <Ctrl>N by creating a MenuItem and using
> MenuItem.setAccelerator(SWT.CONTROL | 'n'). This menu item will be invoked
> instead of IE.
>
> Chris
>
>
Re: Browser Widget and <Ctrl> N [message #451746 is a reply to message #451736] Tue, 08 March 2005 12:30 Go to previous messageGo to next message
Veronika Irvine is currently offline Veronika IrvineFriend
Messages: 1272
Registered: July 2009
Senior Member
Popup menus can't define accelerators as you have discovered. Also activeX
controls get to process accelerators before the application and therefore
even if you had a menu bar that defined the Ctrl N accelerator, IE would
process it first.

I think you can stop the new window using the OpenWindow event. The javadoc
for it says:

* The navigation is cancelled if the event.required field is set to
* true and the event.browser field is left <code>null</code>.

Did this really not work?


"Kalman" <kalman@zikal.com> wrote in message
news:d0i6qe$ecd$1@www.eclipse.org...
> If you have a pop up menu on the browser - the accelerator doesn't get
> called, and a regular menu you got to have a shell (Decoration for). I
> need
> to create a createBrowser() method that will give me back a Browser that
> will ignore Control-N.
>
> there's got to be a better way !!!
>
> Veronika, any ideas?
>
>
>
> "Christophe Cornu" <christophe_cornu@ca.ibm.com> wrote in message
> news:d0i00k$bmm$1@www.eclipse.org...
>> Hi Kalman,
>>
>> You can redirect <Ctrl>N by creating a MenuItem and using
>> MenuItem.setAccelerator(SWT.CONTROL | 'n'). This menu item will be
>> invoked
>> instead of IE.
>>
>> Chris
>>
>>
>
>
Re: Browser Widget and <Ctrl> N [message #451751 is a reply to message #451746] Tue, 08 March 2005 15:04 Go to previous messageGo to next message
Kalman Hazins is currently offline Kalman HazinsFriend
Messages: 76
Registered: July 2009
Member
Veronika,

I tried the following code:

Browser browser = new Browser(parent, style);
browser.addOpenWindowListener(new OpenWindowListener() {
public void open(WindowEvent event) {
System.out.println("\n\nOPEN NEW BROWSER\n\n");
return;
}
});

When I hold down the shift key and click on a link inside the browser
widget - it goes into the open() method and prints OPEN NEW BROWSER, but
when I press <CTRL> N - it just opens C drive without going into the open()
method.

So, yes, I tried it and it didn't work.

Thanx,
- Kalman


"Veronika Irvine" <veronika_irvine@oti.com> wrote in message
news:d0k5sn$8vp$1@www.eclipse.org...
> Popup menus can't define accelerators as you have discovered. Also
activeX
> controls get to process accelerators before the application and therefore
> even if you had a menu bar that defined the Ctrl N accelerator, IE would
> process it first.
>
> I think you can stop the new window using the OpenWindow event. The
javadoc
> for it says:
>
> * The navigation is cancelled if the event.required field is set to
> * true and the event.browser field is left <code>null</code>.
>
> Did this really not work?
>
>
> "Kalman" <kalman@zikal.com> wrote in message
> news:d0i6qe$ecd$1@www.eclipse.org...
> > If you have a pop up menu on the browser - the accelerator doesn't get
> > called, and a regular menu you got to have a shell (Decoration for). I
> > need
> > to create a createBrowser() method that will give me back a Browser that
> > will ignore Control-N.
> >
> > there's got to be a better way !!!
> >
> > Veronika, any ideas?
> >
> >
> >
> > "Christophe Cornu" <christophe_cornu@ca.ibm.com> wrote in message
> > news:d0i00k$bmm$1@www.eclipse.org...
> >> Hi Kalman,
> >>
> >> You can redirect <Ctrl>N by creating a MenuItem and using
> >> MenuItem.setAccelerator(SWT.CONTROL | 'n'). This menu item will be
> >> invoked
> >> instead of IE.
> >>
> >> Chris
> >>
> >>
> >
> >
>
>
Re: Browser Widget and <Ctrl> N [message #451752 is a reply to message #451746] Tue, 08 March 2005 15:14 Go to previous messageGo to next message
Christophe Cornu is currently offline Christophe CornuFriend
Messages: 304
Registered: July 2009
Senior Member
> even if you had a menu bar that defined the Ctrl N accelerator, IE would
> process it first.
The SWT Browser takes care of that. SWT Menu items accelerators take
precedence over IE shortcuts when using the SWT Browser.

Kalman: I've opened the bug report below so that CTRL-N does not run IE
behaviour when Browser.setText is used.
https://bugs.eclipse.org/bugs/show_bug.cgi?id=87372

Chris
Re: Browser Widget and <Ctrl> N [message #451754 is a reply to message #451752] Tue, 08 March 2005 15:47 Go to previous messageGo to next message
Kalman Hazins is currently offline Kalman HazinsFriend
Messages: 76
Registered: July 2009
Member
Chris,

can you suggest a workaround for the time being?

Thanx,
- Kalman

"Christophe Cornu" <christophe_cornu@ca.ibm.com> wrote in message
news:d0kfgd$vjv$1@www.eclipse.org...
> > even if you had a menu bar that defined the Ctrl N accelerator, IE would
> > process it first.
> The SWT Browser takes care of that. SWT Menu items accelerators take
> precedence over IE shortcuts when using the SWT Browser.
>
> Kalman: I've opened the bug report below so that CTRL-N does not run IE
> behaviour when Browser.setText is used.
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=87372
>
> Chris
>
>
>
Re: Browser Widget and <Ctrl> N [message #451761 is a reply to message #451754] Tue, 08 March 2005 16:46 Go to previous messageGo to next message
Christophe Cornu is currently offline Christophe CornuFriend
Messages: 304
Registered: July 2009
Senior Member
With existing builds, you need to define a menu item with an accelerator
that overrides one used by IE. See snippet below.

The fix has just been released in HEAD. The next nightly build or
integration build next week will contain the change. CTRL-N will not cause a
standalone IE to open when the content in the Browser is set from memory
(Browser.setText). If you know of any other IE accelerators that cause you
trouble, please pass them on to bug 87372. Thanks!

Chris


import org.eclipse.swt.*;
import org.eclipse.swt.widgets.*;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.browser.*;

public class PRBrowser {

public static void main(String[] args) {
Display display = new Display();
Shell shell = new Shell(display);
Menu bar = new Menu(shell, SWT.BAR);
MenuItem item = new MenuItem(bar, SWT.CASCADE);
item.setAccelerator(SWT.CONTROL | 'n');
item.addListener(SWT.Selection, new Listener(){
public void handleEvent(Event e) {
System.out.println("ACCELERATOR");
}
});
item.setText("My Menu");
shell.setMenuBar(bar);
shell.setText("PRBrowser");
shell.setLayout(new FillLayout());
Browser browser = new Browser(shell, SWT.NONE);
browser.setText("<html><body>Hello</body></html>");
shell.open();

while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
}
}
Re: Browser Widget and <Ctrl> N [message #451763 is a reply to message #451761] Tue, 08 March 2005 16:56 Go to previous message
Kalman Hazins is currently offline Kalman HazinsFriend
Messages: 76
Registered: July 2009
Member
You are the man! I can wait for milestone 6 (as long as it's fixed)

Thanx,
- Kalman

"Christophe Cornu" <christophe_cornu@ca.ibm.com> wrote in message
news:d0kktm$uqb$1@www.eclipse.org...
> With existing builds, you need to define a menu item with an accelerator
> that overrides one used by IE. See snippet below.
>
> The fix has just been released in HEAD. The next nightly build or
> integration build next week will contain the change. CTRL-N will not cause
a
> standalone IE to open when the content in the Browser is set from memory
> (Browser.setText). If you know of any other IE accelerators that cause you
> trouble, please pass them on to bug 87372. Thanks!
>
> Chris
>
>
> import org.eclipse.swt.*;
> import org.eclipse.swt.widgets.*;
> import org.eclipse.swt.layout.*;
> import org.eclipse.swt.browser.*;
>
> public class PRBrowser {
>
> public static void main(String[] args) {
> Display display = new Display();
> Shell shell = new Shell(display);
> Menu bar = new Menu(shell, SWT.BAR);
> MenuItem item = new MenuItem(bar, SWT.CASCADE);
> item.setAccelerator(SWT.CONTROL | 'n');
> item.addListener(SWT.Selection, new Listener(){
> public void handleEvent(Event e) {
> System.out.println("ACCELERATOR");
> }
> });
> item.setText("My Menu");
> shell.setMenuBar(bar);
> shell.setText("PRBrowser");
> shell.setLayout(new FillLayout());
> Browser browser = new Browser(shell, SWT.NONE);
> browser.setText("<html><body>Hello</body></html>");
> shell.open();
>
> while (!shell.isDisposed()) {
> if (!display.readAndDispatch())
> display.sleep();
> }
> }
> }
>
>
Previous Topic:change in handling of MenuDetect events ?
Next Topic:Different radio button groupings in the same shell
Goto Forum:
  


Current Time: Fri Apr 26 13:02:56 GMT 2024

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

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

Back to the top