When I press CTRL + Scroll the mouse wheel at the same time, it works, but when I release the CTRL key and continue scrolling, it still works. I want it to work only when the CTRL and mouse keys scroll at the same time.
addKeyListener(new KeyListener() {
@Override
public void keyPressed(KeyEvent e) {
addMouseWheelListener(new MouseWheelListener() {
@Override
public void mouseScrolled(MouseEvent g) {
if(e.keyCode == SWT.CTRL){
if(g.count > 0){
System.out.println("up");
int width = getSize().x;
int height = getSize().y;
setSize((int)(width * 1.05), (int)(height * 1.05));
}
else {
System.out.println("down");
int width = getSize().x;
int height = getSize().y;
setSize((int)(width * 0.95), (int)(height * 0.95));
}
}
}
});
}
}
source
share