From ce908d9dca755361230746b9984a205b6f0b9864 Mon Sep 17 00:00:00 2001 From: kerry Date: Wed, 29 Jul 2020 11:26:19 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=BF=AB=E6=8D=B7=E9=94=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/mainframe/FormArea.java | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/designer-form/src/main/java/com/fr/design/mainframe/FormArea.java b/designer-form/src/main/java/com/fr/design/mainframe/FormArea.java index d92ca80a8..88b1b8ba2 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/FormArea.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/FormArea.java @@ -25,8 +25,10 @@ import com.fr.general.FRScreen; import com.fr.stable.AssistUtils; +import javax.swing.AbstractAction; import javax.swing.JComponent; import javax.swing.JPanel; +import javax.swing.KeyStroke; import javax.swing.border.LineBorder; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; @@ -43,12 +45,17 @@ import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.FocusAdapter; import java.awt.event.FocusEvent; +import java.awt.event.KeyEvent; import java.awt.event.MouseWheelEvent; import java.awt.event.MouseWheelListener; +import static com.fr.design.gui.syntax.ui.rtextarea.RTADefaultInputMap.DEFAULT_MODIFIER; + public class FormArea extends JComponent implements ScrollRulerComponent { private static final double SLIDER_FLOAT = 400.0; private static final double SLIDER_MIN = 10.0; + private static final String SCALE_PLUS_COMMAND = "scale_plus"; + private static final String SCALE_MINUS_COMMAND = "scale_minus"; public static final double DEFAULT_SLIDER = 100.0; private static final int ROTATIONS = 50; private static final int SHOWVALMAX = 400; @@ -107,8 +114,31 @@ public class FormArea extends JComponent implements ScrollRulerComponent { } this.setFocusTraversalKeysEnabled(false); this.addMouseWheelListener(showValSpinnerMouseWheelListener); + registerShortCutKey(); + } + /** + * 注册缩放快捷键 + * mac: command + 和 command - + * windows: ctr + 和 ctr - + */ + private void registerShortCutKey() { + this.registerKeyboardAction(new AbstractAction() { + @Override + public void actionPerformed(ActionEvent e) { + int old_resolution = slidePane.getShowValue(); + slidePane.setShowValue(old_resolution + SHOWVALMIN); + } + }, SCALE_PLUS_COMMAND, KeyStroke.getKeyStroke(KeyEvent.VK_EQUALS, DEFAULT_MODIFIER), WHEN_IN_FOCUSED_WINDOW); + this.registerKeyboardAction(new AbstractAction() { + @Override + public void actionPerformed(ActionEvent e) { + int old_resolution = slidePane.getShowValue(); + slidePane.setShowValue(old_resolution - SHOWVALMIN); + } + }, SCALE_MINUS_COMMAND, KeyStroke.getKeyStroke(KeyEvent.VK_MINUS, DEFAULT_MODIFIER), WHEN_IN_FOCUSED_WINDOW); + } public void onMobileAttrModified() { FormMobileAttr formMobileAttr = designer.getTarget().getFormMobileAttr();