Browse Source

添加快捷键

feature/big-screen
kerry 4 years ago
parent
commit
ce908d9dca
  1. 30
      designer-form/src/main/java/com/fr/design/mainframe/FormArea.java

30
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();

Loading…
Cancel
Save