1
0
mirror of https://github.com/Toxblh/MTMR.git synced 2026-01-10 00:58:37 +00:00

CustomButtonTouchBarItem: try to fix strange app hanging (attempt 2)

This commit is contained in:
bobrosoft 2019-08-06 15:03:01 +02:00
parent 229c55c367
commit 63e3de7313

View File

@ -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()
}