Merge pull request #110 from Hufe921/feature/selection-shortcut

Feature/selection shortcut
pr675
Hufe 3 years ago committed by GitHub
commit 5cb2187b0a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -12,9 +12,15 @@
## ← ## ←
功能:向左移动 功能:向左移动
## Shift + ←
功能:向左扩大选区
## → ## →
功能:向右移动 功能:向右移动
## Shift + →
功能:向右扩大选区
## ↑ ## ↑
功能:向上移动 功能:向上移动

@ -88,24 +88,30 @@ export function keydown(evt: KeyboardEvent, host: CanvasEvent) {
} else if (evt.key === KeyMap.Left) { } else if (evt.key === KeyMap.Left) {
if (isReadonly) return if (isReadonly) return
if (index > 0) { if (index > 0) {
const curIndex = index - 1 const curIndex = startIndex - 1
rangeManager.setRange(curIndex, curIndex) // shift则向左扩大选区
const anchorIndex = evt.shiftKey ? endIndex : curIndex
rangeManager.setRange(curIndex, anchorIndex)
draw.render({ draw.render({
curIndex, curIndex,
isSubmitHistory: false, isSubmitHistory: false,
isComputeRowList: false isComputeRowList: false
}) })
evt.preventDefault()
} }
} else if (evt.key === KeyMap.Right) { } else if (evt.key === KeyMap.Right) {
if (isReadonly) return if (isReadonly) return
if (index < positionList.length - 1) { if (index < positionList.length - 1) {
const curIndex = index + 1 const curIndex = endIndex + 1
rangeManager.setRange(curIndex, curIndex) // shift则向右扩大选区
const anchorIndex = evt.shiftKey ? startIndex : curIndex
rangeManager.setRange(anchorIndex, curIndex)
draw.render({ draw.render({
curIndex, curIndex,
isSubmitHistory: false, isSubmitHistory: false,
isComputeRowList: false isComputeRowList: false
}) })
evt.preventDefault()
} }
} else if (evt.key === KeyMap.Up || evt.key === KeyMap.Down) { } else if (evt.key === KeyMap.Up || evt.key === KeyMap.Down) {
if (isReadonly) return if (isReadonly) return

Loading…
Cancel
Save