Skip to content

Commit

Permalink
快捷键修改兼容mac
Browse files Browse the repository at this point in the history
  • Loading branch information
lingxiaoyi committed Sep 26, 2019
1 parent 91704f7 commit ece7c0d
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import _ from 'lodash';
import jrQrcode from 'jr-qrcode';
import { Button, Input, message, Select, Modal, Drawer, Radio } from 'antd';
import copy from 'copy-to-clipboard';
import keydown from 'react-keydown';
import keydown, { ALL_KEYS } from 'react-keydown';
import ReactMarkdown from 'react-markdown';
import json from 'format-json';
import { optionArr, newOptionArr } from './optionArr';
Expand Down Expand Up @@ -180,10 +180,13 @@ class App extends React.Component {
that.updateCanvasState();
});
}
@keydown(['ctrl+left', 'ctrl+right', 'ctrl+up', 'ctrl+down', 'ctrl+z', 'ctrl+y', 'delete', '[', ']'])
@keydown(/* ['ctrl+left', 'ctrl+right', 'ctrl+up', 'ctrl+down', 'ctrl+z', 'ctrl+y', 'delete', '[', ']'] */ ALL_KEYS)
beginEdit(event) {
//console.log('event', event, event.which);
let that = this;
if (that.activeObject.type) {
let activeObject = this.canvas_sprite.getActiveObject();
//console.log('activeObject', activeObject);
if (activeObject) {
//console.log('that.activeObject', that.activeObject);
if (event.which === 37) {
//左
Expand Down Expand Up @@ -225,17 +228,20 @@ class App extends React.Component {
this.canvas_sprite.discardActiveObject();
that.activeObject.sendBackwards(true);
this.changeActiveObjectValue();
} else if (event.which === 90) {
} else if (event.which === 90 && event.ctrlKey) {
//ctrl+z
that.handerUndo();
this.changeActiveObjectValue();
} else if (event.which === 89) {
} else if (event.which === 89 && event.ctrlKey) {
//ctrl+y
that.handerRedo();
this.changeActiveObjectValue();
} else if (event.which === 46) {
//delete
this.canvas_sprite.remove(that.activeObject);
} else if (event.which === 46 || event.which === 8) {
//delete backspace
this.canvas_sprite.remove(activeObject);
that.setState({
visible: false
});
}
this.canvas_sprite.renderAll();
}
Expand Down

0 comments on commit ece7c0d

Please sign in to comment.