1
0
mirror of https://github.com/Toxblh/MTMR.git synced 2026-01-11 09:28:38 +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!) let touches = event.touches(for: self.view!)
if touches.count == 1 { // to prevent it for built-in two/three-finger gestures if touches.count == 1 { // to prevent it for built-in two/three-finger gestures
timer = Timer.scheduledTimer(withTimeInterval: recognizeTimeout, repeats: false) { [weak self] _ in timer = Timer.scheduledTimer(timeInterval: 0.25, target: self, selector: #selector(self.onTimer), userInfo: nil, repeats: false)
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)
}
}
} }
super.touchesBegan(with: event) 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 { deinit {
timerInvalidate() timerInvalidate()
} }