[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.platform.swt] Passing events from Widget to Widget

Hi,

I've got the following problem. I'm opening a Shell as a ToolTip and of the user clicks the shell the Event should get passed on to the Widget below the ToolTip (See a complete description of the problem in https://bugs.eclipse.org/bugs/show_bug.cgi?id=195137).

On Win32 this works with the code attached but on OS-X it is not working! The question is now whichone behaves correct. It is also possible that I'm doing something completely stupied which has to be done differently.

Could someone from the SWT-Team have a look and tell me/us how this can be resolved?

Tom

--
B e s t S o l u t i o n . at
--------------------------------------------------------------------
Tom Schindl                                          JFace-Committer
--------------------------------------------------------------------
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.MouseMoveListener;
import org.eclipse.swt.events.MouseTrackListener;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableItem;


public class TestClickThrough {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		final Display display = new Display ();
		final Shell shell = new Shell(display);
		shell.setLayout(new FillLayout());

		Table t = new Table(shell,SWT.FULL_SELECTION);
		for( int i = 0; i < 10; i++ ) {
			new TableItem(t,SWT.NONE).setText("Test Test Test Test" + 1);
		}

		t.addSelectionListener(new SelectionListener() {

			public void widgetDefaultSelected(SelectionEvent e) {
				// TODO Auto-generated method stub

			}

			public void widgetSelected(SelectionEvent e) {
				System.err.println("SELECTED: " + e.item);
			}

		});
		t.addMouseTrackListener(new MouseTrackListener() {

			public void mouseEnter(MouseEvent e) {
				// TODO Auto-generated method stub

			}

			public void mouseExit(MouseEvent e) {
				// TODO Auto-generated method stub

			}

			public void mouseHover(MouseEvent e) {
				final Shell s = new Shell(shell);
				s.setLocation(0, 0);
				s.setSize(200, 200);
				s.addListener(SWT.MouseDown, new Listener() {

					public void handleEvent(Event event) {
						s.close();
						display.post(event);
					}

				});
				s.open();
			}

		});

		shell.open ();

		while (!shell.isDisposed ()) {
			if (!display.readAndDispatch ()) display.sleep ();
		}

		display.dispose ();

	}

}