Skip to content

Commit a362198

Browse files
committed
Implement MouseWheelListener on tabs
tested with Marlin Firmware, solves #6109 #3601 #1193
1 parent 80a15e8 commit a362198

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

app/src/processing/app/EditorHeader.java

+22
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@
2727
import processing.app.helpers.OSUtils;
2828
import processing.app.helpers.SimpleAction;
2929
import processing.app.tools.MenuScroller;
30+
import java.awt.event.MouseWheelListener;
31+
import java.awt.event.MouseWheelEvent;
32+
3033
import static processing.app.I18n.tr;
3134

3235
import java.awt.*;
@@ -189,6 +192,25 @@ public void mousePressed(MouseEvent e) {
189192
}
190193
}
191194
});
195+
196+
this.addMouseWheelListener(new MouseAdapter() {
197+
public void mouseWheelMoved(MouseWheelEvent e) {
198+
if (e.getWheelRotation() > 0) {
199+
int index = editor.getCurrentTabIndex() + 1;
200+
if (index >= (editor.getTabs().size())) {
201+
index = 0;
202+
}
203+
editor.selectTab(index);
204+
} else {
205+
int index = editor.getCurrentTabIndex() - 1;
206+
if (index < 0) {
207+
index = editor.getTabs().size() -1 ;
208+
}
209+
editor.selectTab(index);
210+
}
211+
repaint();
212+
}
213+
});
192214
}
193215

194216

0 commit comments

Comments
 (0)