Skip to content

Commit

Permalink
fix scrolling: ctrl|cmd zooms, shift|alt scrolls horizontally
Browse files Browse the repository at this point in the history
  • Loading branch information
bertsky committed Nov 13, 2020
1 parent a6c7998 commit 9cfcd81
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,9 @@ private void init() {
imageCanvas.addMouseTrackListener(this);
imageCanvas.addMouseMoveListener(this);

parent.addMouseWheelListener(imageCanvas);
//parent.addMouseMoveListener(imageCanvas);
parent.addMouseWheelListener(this);
imageCanvas.addMouseWheelListener(imageCanvas);
//imageCanvas.addMouseMoveListener(imageCanvas);
imageCanvas.addMouseWheelListener(this);

tooltip = new PageElementTooltip(viewPane.getShell());
tooltip.activateHoverHelp(imageCanvas);
Expand Down Expand Up @@ -748,7 +748,8 @@ public void mouseMove(MouseEvent e) {

@Override
public void mouseScrolled(MouseEvent e) {
if ((e.stateMask & SWT.MOD1) != 0) { //CTRL
// non-CTRL already handled by SWTImageCanvas
if ((e.stateMask & (SWT.CTRL | SWT.COMMAND)) != 0) {
if (e.count > 0)
zoomIn();
else
Expand Down
15 changes: 11 additions & 4 deletions src/uky/article/imageviewer/views/SWTImageCanvas.java
Original file line number Diff line number Diff line change
Expand Up @@ -421,10 +421,17 @@ public AffineTransform getTransform() {

@Override
public void mouseScrolled(MouseEvent e) {
if ((e.stateMask & SWT.MOD1) == 0) { //No CTRL
ScrollBar scrollBar = getVerticalBar();
scrollBar.setSelection(scrollBar.getSelection()-e.count*10);
scrollVertically(scrollBar);
// CTRL already handled by DocumentImageView
if ((e.stateMask & (SWT.CTRL | SWT.COMMAND)) == 0) {
if ((e.stateMask & (SWT.SHIFT | SWT.ALT)) != 0) {
ScrollBar scrollBar = getHorizontalBar();
scrollBar.setSelection(scrollBar.getSelection()-e.count*10);
scrollHorizontally(scrollBar);
} else {
ScrollBar scrollBar = getVerticalBar();
scrollBar.setSelection(scrollBar.getSelection()-e.count*10);
scrollVertically(scrollBar);
}
}
}

Expand Down

0 comments on commit 9cfcd81

Please sign in to comment.