From 12a8768c5510e625ee0ea370cf3119e4763aa2fa Mon Sep 17 00:00:00 2001 From: tisfeng Date: Fri, 22 Dec 2023 20:57:34 +0800 Subject: [PATCH] perf: only monitor key down event when enable autoSelectText --- Easydict/Feature/EventMonitor/EZEventMonitor.m | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Easydict/Feature/EventMonitor/EZEventMonitor.m b/Easydict/Feature/EventMonitor/EZEventMonitor.m index 1734fa0a4..2578efd37 100644 --- a/Easydict/Feature/EventMonitor/EZEventMonitor.m +++ b/Easydict/Feature/EventMonitor/EZEventMonitor.m @@ -194,8 +194,6 @@ - (void)start { // Monitor global events, Ref: https://blog.csdn.net/ch_soft/article/details/7371136 - (void)startMonitor { - [self monitorCGEventTap]; - [NSEvent addLocalMonitorForEventsMatchingMask:NSEventMaskKeyDown handler:^NSEvent *_Nullable(NSEvent *_Nonnull event) { if (event.keyCode == kVK_Escape) { // escape NSLog(@"escape"); @@ -302,7 +300,9 @@ - (void)getSelectedText:(BOOL)checkTextFrame completion:(void (^)(NSString *_Nul self.selectTextType = EZSelectTextTypeAccessibility; // Monitor CGEventTap must be required after using Accessibility successfully. - [self monitorCGEventTap]; + if (EZConfiguration.shared.autoSelectText) { + [self monitorCGEventTap]; + } self.selectedTextEditable = [EZSystemUtility isSelectedTextEditable];