diff --git a/MTMR/CustomButtonTouchBarItem.swift b/MTMR/CustomButtonTouchBarItem.swift index c9d4306..428ca05 100644 --- a/MTMR/CustomButtonTouchBarItem.swift +++ b/MTMR/CustomButtonTouchBarItem.swift @@ -190,12 +190,7 @@ class LongPressGestureRecognizer: NSPressGestureRecognizer { let touches = event.touches(for: self.view!) if touches.count == 1 { // to prevent it for built-in two/three-finger gestures - timer = Timer.scheduledTimer(withTimeInterval: recognizeTimeout, repeats: false) { [weak self] _ in - if let _self = self, let target = self?.target, let action = self?.action { - target.performSelector(onMainThread: action, with: _self, waitUntilDone: false) - HapticFeedback.shared.tap(strong: 6) - } - } + timer = Timer.scheduledTimer(timeInterval: 0.25, target: self, selector: #selector(self.onTimer), userInfo: nil, repeats: false) } super.touchesBegan(with: event) @@ -223,6 +218,13 @@ class LongPressGestureRecognizer: NSPressGestureRecognizer { } } + @objc private func onTimer() { + if let target = self.target, let action = self.action { + target.performSelector(onMainThread: action, with: self, waitUntilDone: false) + HapticFeedback.shared.tap(strong: 6) + } + } + deinit { timerInvalidate() }