fix(SelectionAssistant): ignore ctrl pressing when user is zooming in/out (#6822)

* fix(SelectionService): ignore ctrl pressing when user is zomming in/out

* chore: rename function

* fix: reset listener status
This commit is contained in:
fullex 2025-06-05 14:28:50 +08:00 committed by GitHub
parent a9c644d209
commit 19ff35b779

View File

@ -304,7 +304,12 @@ export class SelectionService {
if (!this.selectionHook) return false
this.selectionHook.stop()
this.selectionHook.cleanup()
this.selectionHook.cleanup() //already remove all listeners
//reset the listener states
this.isCtrlkeyListenerActive = false
this.isHideByMouseKeyListenerActive = false
if (this.toolbarWindow) {
this.toolbarWindow.close()
this.toolbarWindow = null
@ -836,6 +841,8 @@ export class SelectionService {
//ctrlkey pressed
if (this.lastCtrlkeyDownTime === 0) {
this.lastCtrlkeyDownTime = Date.now()
//add the mouse-wheel listener, detect if user is zooming in/out
this.selectionHook!.on('mouse-wheel', this.handleMouseWheelCtrlkeyMode)
return
}
@ -859,9 +866,20 @@ export class SelectionService {
*/
private handleKeyUpCtrlkeyMode = (data: KeyboardEventData) => {
if (!this.isCtrlkey(data.vkCode)) return
//remove the mouse-wheel listener
this.selectionHook!.off('mouse-wheel', this.handleMouseWheelCtrlkeyMode)
this.lastCtrlkeyDownTime = 0
}
/**
* Handle mouse wheel events in ctrlkey trigger mode
* ignore CtrlKey pressing when mouse wheel is used
* because user is zooming in/out
*/
private handleMouseWheelCtrlkeyMode = () => {
this.lastCtrlkeyDownTime = -1
}
//check if the key is ctrl key
private isCtrlkey(vkCode: number) {
return vkCode === 162 || vkCode === 163