| Summary: | RWT vs SWT difference - Selection Listener on top-level MenuItem does not fire in RWT/RAP | ||
|---|---|---|---|
| Product: | [RT] RAP | Reporter: | John Gymer <jgymer> |
| Component: | RWT | Assignee: | Project Inbox <rap-inbox> |
| Status: | RESOLVED FIXED | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | ||
| Version: | 2.0 | ||
| Target Milestone: | 2.1 M1 | ||
| Hardware: | PC | ||
| OS: | Windows 7 | ||
| Whiteboard: | |||
It's true, selection listeners are not supported on MenuBar items in RWT, but they are in SWT. I noticed that in GTK, only every second click on a MenuBar item leads to a selection event. Apparently, a MenuBar item without a menu still acts as if it had a menu attached–the first click is supposed to open the menu, the second one to close it. I guess that this behavior limits the use of a selection listener on a menu bar item. Does that mean that it will be treated as a bug, with a fix forthcoming, or just have to accept a behaviour difference? If the latter, then this limits conversion of a variety of SWT applications 'as-is', and I don't see any specific reason to have this difference? I'm not against fixing this in RAP, but don't consider it high priority. It's not a regression and it seems that selection listeners on menu bar items are of limited use due to the behavior described in comment 1. John, what do you use the listeners for? Do you have menu bar items without a menu attached? Hi Ralf, I would certainly appreciate this being treated as a required fix... ...we are developing a runtime that will allow automatic conversion (re-generation in fact) of many large corporate applications from another technology to run on RAP as the front-end, and I know that I've come across numerous of our customers who do use single-level menu bars. While I don't particularly like or agree with that type of design of menu personally, it makes sense to offer as seamless a transition as possible, with as few manual changes to their applications in the process. Who are we to prescribe how customers design their apps anyway? We might not agree, but in principle it is a reasonable standard. Not high priority of course, but I assume that it would be a simple fix internally in the RAP runtime, so would hope that it won't be too long in the coming? Best regards, John Fixed in master with commit bd95c0fdd125f3ae6f2b85c77a55577f83c07550. Thanks Ivan, I'll retest when I get a chance... have only just updated to 20130205, so might be a while before I do it ;-) Thanks, John |
The following snippet, when run under RAP with the EntryPoint simply calling main() below, shows that the Selection Listener is never fired for a MenuItem where the MenuItem is the top-level menu i.e. a menu that has no drop-down children. This event is correctly triggered in SWT, but not in RWT... 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!"); } }; }