mirror of
https://github.com/Toxblh/MTMR.git
synced 2026-01-11 17:38:38 +00:00
CustomButtonTouchBarItem: try to fix strange app hanging
This commit is contained in:
parent
11530ef180
commit
229c55c367
@ -190,9 +190,9 @@ 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) { _ in
|
timer = Timer.scheduledTimer(withTimeInterval: recognizeTimeout, repeats: false) { [weak self] _ in
|
||||||
if let target = self.target, let action = self.action {
|
if let _self = self, let target = self?.target, let action = self?.action {
|
||||||
target.performSelector(inBackground: action, with: self)
|
target.performSelector(onMainThread: action, with: _self, waitUntilDone: false)
|
||||||
HapticFeedback.shared.tap(strong: 6)
|
HapticFeedback.shared.tap(strong: 6)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -222,6 +222,10 @@ class LongPressGestureRecognizer: NSPressGestureRecognizer {
|
|||||||
self.timer = nil
|
self.timer = nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
deinit {
|
||||||
|
timerInvalidate()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension String {
|
extension String {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user