mirror of
https://github.com/arduino/Arduino.git
synced 2025-01-19 08:52:15 +01:00
Implement font increse/decrease with CTRL+MouseWheel
This commit is contained in:
parent
c07f8fca54
commit
388822ad95
@ -30,6 +30,9 @@ import java.awt.BorderLayout;
|
||||
import java.awt.Font;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.MouseWheelListener;
|
||||
import java.awt.event.MouseWheelEvent;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.swing.Action;
|
||||
@ -64,7 +67,7 @@ import processing.app.tools.DiscourseFormat;
|
||||
/**
|
||||
* Single tab, editing a single file, in the main window.
|
||||
*/
|
||||
public class EditorTab extends JPanel implements SketchFile.TextStorage {
|
||||
public class EditorTab extends JPanel implements SketchFile.TextStorage, MouseWheelListener {
|
||||
protected Editor editor;
|
||||
protected SketchTextArea textarea;
|
||||
protected RTextScrollPane scrollPane;
|
||||
@ -106,6 +109,7 @@ public class EditorTab extends JPanel implements SketchFile.TextStorage {
|
||||
file.setStorage(this);
|
||||
applyPreferences();
|
||||
add(scrollPane, BorderLayout.CENTER);
|
||||
textarea.addMouseWheelListener(this);
|
||||
}
|
||||
|
||||
private RSyntaxDocument createDocument(String contents) {
|
||||
@ -178,6 +182,18 @@ public class EditorTab extends JPanel implements SketchFile.TextStorage {
|
||||
return textArea;
|
||||
}
|
||||
|
||||
public void mouseWheelMoved(MouseWheelEvent e) {
|
||||
if (e.isControlDown()) {
|
||||
if (e.getWheelRotation() < 0) {
|
||||
editor.base.handleFontSizeChange(1);
|
||||
} else {
|
||||
editor.base.handleFontSizeChange(-1);
|
||||
}
|
||||
} else {
|
||||
e.getComponent().getParent().dispatchEvent(e);
|
||||
}
|
||||
}
|
||||
|
||||
private void configurePopupMenu(final SketchTextArea textarea){
|
||||
|
||||
JPopupMenu menu = textarea.getPopupMenu();
|
||||
|
Loading…
x
Reference in New Issue
Block a user