Community
Participate
Working Groups
Eclipse 3.2/3.3 OS: Windows I would like to programmatically send a Mouse-Wheel-Event to a different Scrollable. The idea is to scroll a Scrollable, even if its not having focus (note that Linux provides this for free). Consider this snippet: public class Main { public static void main(String[] args) { final Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new FillLayout()); Table t = new Table(shell, SWT.None); for (int i = 0; i < 100; i++) { new TableItem(t, SWT.None).setText("Hello World"); } t = new Table(shell, SWT.None); for (int i = 0; i < 100; i++) { new TableItem(t, SWT.None).setText("Hello World"); } display.addFilter(SWT.MouseWheel, new Listener() { public void handleEvent(final Event event) { final Control cursorControl = display.getCursorControl(); if (!cursorControl.isFocusControl()) { event.doit = false; cursorControl.setFocus(); event.widget = cursorControl; cursorControl.notifyListeners(SWT.MouseWheel, event); display.post(event); } } }); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } } } Move the mouse over the second Table to the right and begin scrolling. As you can see, the Table gets focus and begins scrolling, but only for the second scroll-event, not the first one. While its possible to ignore the event for the first Table (event.doit = false), its not possible to send it to the second Table (see my two proposed solutions in lines 26 and 27). It would be cool for this "feature" (I know its working around common OS behavior at least on windows, but tons of people have asked me about it), if also the first mouse-wheel-event is resulting in the second Table to scroll accordingly. Ben
Of course, if it was possible to send this event to the second table, the call to control.setFocus() is no longer necessary (which is a lot better to the current solution). Ben
See also Bug 172167
I think this is fixed in recent builds, right steve?
Yes. Display.post() accepts SWT.MouseWheel, however, you probably should not be overriding the mouse wheel behavior of the operating system. Close?
Ok with me.
Ok, WONTFIX this.