Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
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 Go to next message
John Gymer is currently offline John GymerFriend
Messages: 279
Registered: November 2012
Location: UK
Senior Member
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 Go to previous messageGo to next message
Ivan Furnadjiev is currently offline Ivan FurnadjievFriend
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/
Re: RAP vs SWT Selection Listener for singleton menus [message #1004467 is a reply to message #992424] Wed, 23 January 2013 09:56 Go to previous messageGo to next message
Sebastian Habenicht is currently offline Sebastian HabenichtFriend
Messages: 42
Registered: January 2013
Member
Hi John,

did you raise a bug report for this issue? Can you please post the url to it?
BTW: The issue still occurs with 2.0 RC1

Thanks,
Sebastian
Re: RAP vs SWT Selection Listener for singleton menus [message #1004497 is a reply to message #1004467] Wed, 23 January 2013 10:58 Go to previous message
John Gymer is currently offline John GymerFriend
Messages: 279
Registered: November 2012
Location: UK
Senior Member
Hi Sebastian,
BugZilla link is https://bugs.eclipse.org/bugs/show_bug.cgi?id=397094
Best regards, John


---
Just because you can doesn't mean you should
Previous Topic:SashForm SWT.SMOOTH
Next Topic:Branding with RAP 1.5
Goto Forum:
  


Current Time: Tue Apr 23 13:49:43 GMT 2024

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

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

Back to the top