mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2026-01-01 01:30:51 +08:00
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:
parent
a9c644d209
commit
19ff35b779
@ -304,7 +304,12 @@ export class SelectionService {
|
|||||||
if (!this.selectionHook) return false
|
if (!this.selectionHook) return false
|
||||||
|
|
||||||
this.selectionHook.stop()
|
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) {
|
if (this.toolbarWindow) {
|
||||||
this.toolbarWindow.close()
|
this.toolbarWindow.close()
|
||||||
this.toolbarWindow = null
|
this.toolbarWindow = null
|
||||||
@ -836,6 +841,8 @@ 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
|
||||||
|
this.selectionHook!.on('mouse-wheel', this.handleMouseWheelCtrlkeyMode)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -859,9 +866,20 @@ 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
|
||||||
|
this.selectionHook!.off('mouse-wheel', this.handleMouseWheelCtrlkeyMode)
|
||||||
this.lastCtrlkeyDownTime = 0
|
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
|
//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