mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2026-01-08 14:29:15 +08:00
fix(SelectionAssistant): ignore CtrlKey mode when ctrl+click (#6843)
fix(SelectionService): add mouse-down listener for multi-selection in ctrlkey mode
This commit is contained in:
parent
36f56ba9aa
commit
b829abed2d
@ -841,8 +841,9 @@ export class SelectionService {
|
|||||||
//ctrlkey pressed
|
//ctrlkey pressed
|
||||||
if (this.lastCtrlkeyDownTime === 0) {
|
if (this.lastCtrlkeyDownTime === 0) {
|
||||||
this.lastCtrlkeyDownTime = Date.now()
|
this.lastCtrlkeyDownTime = Date.now()
|
||||||
//add the mouse-wheel listener, detect if user is zooming in/out
|
//add the mouse-wheel&mouse-down listener, detect if user is zooming in/out or multi-selecting
|
||||||
this.selectionHook!.on('mouse-wheel', this.handleMouseWheelCtrlkeyMode)
|
this.selectionHook!.on('mouse-wheel', this.handleMouseWheelCtrlkeyMode)
|
||||||
|
this.selectionHook!.on('mouse-down', this.handleMouseDownCtrlkeyMode)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -866,8 +867,9 @@ export class SelectionService {
|
|||||||
*/
|
*/
|
||||||
private handleKeyUpCtrlkeyMode = (data: KeyboardEventData) => {
|
private handleKeyUpCtrlkeyMode = (data: KeyboardEventData) => {
|
||||||
if (!this.isCtrlkey(data.vkCode)) return
|
if (!this.isCtrlkey(data.vkCode)) return
|
||||||
//remove the mouse-wheel listener
|
//remove the mouse-wheel&mouse-down listener
|
||||||
this.selectionHook!.off('mouse-wheel', this.handleMouseWheelCtrlkeyMode)
|
this.selectionHook!.off('mouse-wheel', this.handleMouseWheelCtrlkeyMode)
|
||||||
|
this.selectionHook!.off('mouse-down', this.handleMouseDownCtrlkeyMode)
|
||||||
this.lastCtrlkeyDownTime = 0
|
this.lastCtrlkeyDownTime = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -880,6 +882,15 @@ export class SelectionService {
|
|||||||
this.lastCtrlkeyDownTime = -1
|
this.lastCtrlkeyDownTime = -1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle mouse down events in ctrlkey trigger mode
|
||||||
|
* ignore CtrlKey pressing when mouse down is used
|
||||||
|
* because user is multi-selecting
|
||||||
|
*/
|
||||||
|
private handleMouseDownCtrlkeyMode = () => {
|
||||||
|
this.lastCtrlkeyDownTime = -1
|
||||||
|
}
|
||||||
|
|
||||||
//check if the key is ctrl key
|
//check if the key is ctrl key
|
||||||
private isCtrlkey(vkCode: number) {
|
private isCtrlkey(vkCode: number) {
|
||||||
return vkCode === 162 || vkCode === 163
|
return vkCode === 162 || vkCode === 163
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user