Home » Eclipse Projects » Remote Application Platform (RAP) » RAP vs SWT Selection Listener for singleton menus(Selection event not triggered for singleton menus)
RAP vs SWT Selection Listener for singleton menus [message #992288] |
Fri, 21 December 2012 09:32 |
|
In SWT, if I have a MenuItem at the top level i.e. without any drop-down items, in SWT I can add a SelectionListener, which works ok, with events getting triggered.
However, in RWT/RAP (I'm using 2.0 M3), no event gets triggered. I'm assuming that this is a bug in RWT?
Ok, I know you'll probably say that this is a silly design, and it is, but I have customers using this type of menu design, so I need to be able to support the same architecture, and get Selection events triggered when the user clicks the menu.
Snippet below:
package bug.snippet;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.MenuItem;
import org.eclipse.swt.widgets.Shell;
public class Bugsy {
private static Display display;
private static Shell shell;
private static Menu menu;
private static MenuItem menuItem;
public static void main(String args[]) {
System.out.println("BugSnippy Starting...");
display = new Display();
shell = new Shell(display, SWT.TITLE|SWT.MAX|SWT.MIN|SWT.RESIZE|SWT.CLOSE);
shell.setText("Bugsy");
shell.setSize(300, 150);
menu = new Menu(shell, SWT.BAR);
shell.setMenuBar(menu);
menuItem = new MenuItem(menu, SWT.PUSH);
menuItem.setText("PushMeMenu");
menuItem.addListener(SWT.Selection, listener);
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
display.dispose();
System.out.println("BugSnippy Done!");
}
static Listener listener = new Listener() {
public void handleEvent(Event event) {
System.out.println("MenuItem was pressed!");
}
};
}
EntryPoint for RAP simply runs this main.
Is this a bug in RWT/RAP?
Thanks, John
---
Just because you can doesn't mean you should
|
|
|
Re: RAP vs SWT Selection Listener for singleton menus [message #992424 is a reply to message #992288] |
Fri, 21 December 2012 15:51 |
Ivan Furnadjiev Messages: 2426 Registered: July 2009 Location: Sofia, Bulgaria |
Senior Member |
|
|
Hi John,
if the behavior differs from SWT than it's probably a bug in RWT. Please
open a bugzilla and attach the entry point there.
Thanks,
Ivan
On 12/21/2012 11:32 AM, John Gymer wrote:
> In SWT, if I have a MenuItem at the top level i.e. without any
> drop-down items, in SWT I can add a SelectionListener, which works ok,
> with events getting triggered.
> However, in RWT/RAP (I'm using 2.0 M3), no event gets triggered. I'm
> assuming that this is a bug in RWT?
>
> Ok, I know you'll probably say that this is a silly design, and it is,
> but I have customers using this type of menu design, so I need to be
> able to support the same architecture, and get Selection events
> triggered when the user clicks the menu.
>
> Snippet below:
>
>
> package bug.snippet;
>
> import org.eclipse.swt.SWT;
> import org.eclipse.swt.events.SelectionEvent;
> import org.eclipse.swt.events.SelectionListener;
> import org.eclipse.swt.widgets.Display;
> import org.eclipse.swt.widgets.Event;
> import org.eclipse.swt.widgets.Listener;
> import org.eclipse.swt.widgets.Menu;
> import org.eclipse.swt.widgets.MenuItem;
> import org.eclipse.swt.widgets.Shell;
>
> public class Bugsy {
> private static Display display;
> private static Shell shell;
> private static Menu menu;
> private static MenuItem menuItem;
>
> public static void main(String args[]) {
> System.out.println("BugSnippy Starting...");
>
> display = new Display();
> shell = new Shell(display,
> SWT.TITLE|SWT.MAX|SWT.MIN|SWT.RESIZE|SWT.CLOSE);
> shell.setText("Bugsy");
> shell.setSize(300, 150);
> menu = new Menu(shell, SWT.BAR);
> shell.setMenuBar(menu);
> menuItem = new MenuItem(menu, SWT.PUSH);
> menuItem.setText("PushMeMenu");
> menuItem.addListener(SWT.Selection, listener);
> shell.open();
>
> while (!shell.isDisposed()) {
> if (!display.readAndDispatch())
> display.sleep();
> }
> display.dispose();
>
> System.out.println("BugSnippy Done!");
> }
>
> static Listener listener = new Listener() {
> public void handleEvent(Event event) {
> System.out.println("MenuItem was pressed!");
> }
> };
>
> }
>
>
> EntryPoint for RAP simply runs this main.
>
> Is this a bug in RWT/RAP?
> Thanks, John
>
--
Ivan Furnadjiev
Twitter: @EclipseRAP
Blog: http://eclipsesource.com/blogs/
Professional services for RAP and RCP?
http://eclipsesource.com/services/rap/
|
|
| | |
Goto Forum:
Current Time: Wed Apr 24 19:01:03 GMT 2024
Powered by FUDForum. Page generated in 0.03436 seconds
|