I have done research into this for a while now and have found very little information on SWT MouseWheelListeners
. Looking to see if any of you have encountered this or have a link to something that could help explain them.
I am trying to find out information on the SWT MouseWheelListener
and how it is used appropriately. I am attempting to use the MouseWheelListener
to create a zoom effect on a composite which draws multiple composite objects on it.
In essence, when wheeling up zoom in by redrawing the canvas at twice normal size, repainting objects on the canvas in a proportional layout, and moving the focus to the point wheeled on.
My questions are the following:
Is it possible to use a MouseWheelListener
on a Composite or is the listener only for objects like scrolled composites (I know the method is there; nothing is happening when I attempt to scroll on my object (including at debug)?
How to kick off a MouseScrolledEvent
on a Composite
if possible?
How to differentiate between wheel up and wheel down (e.count is positive for up & negative for down)?
Code follows:
public TagCloudComposite(Composite parent, int style) {
super(parent, style);
addMouseWheelListener(new MouseWheelListener() {
public void mouseScrolled(MouseEvent e) {
int count = e.count;
System.out.println(count);
// int direction = (Math.abs(count) > 0) ? UP : DOWN;
// changeBackground(direction);
}
});
this.setLayout(new FillLayout());
this.setMinWeight(1);
this.setMaxWeight(100);
c = new Composite(this, SWT.NONE);
this.setSize(300, 200);
}