4
當我按CTRL +同時滾動鼠標滾輪時,它的作用是 ,但是當我釋放CTRL鍵並繼續滾動時,它仍然有效。 我希望它只在CTRL和鼠標滾輪同時滾動時工作。按CTRL +鼠標滾輪會放大
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));
}
}
}
});
}
}