Skip to content

Commit

Permalink
perf: only monitor key down event when enable autoSelectText
Browse files Browse the repository at this point in the history
  • Loading branch information
tisfeng committed Dec 22, 2023
1 parent c02148a commit 12a8768
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions Easydict/Feature/EventMonitor/EZEventMonitor.m
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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];

Expand Down

0 comments on commit 12a8768

Please sign in to comment.