mhdhejazi / Dynamic

Call hidden/private API in style! The Swift way.
https://medium.com/@mhdhejazi/calling-ios-and-macos-hidden-api-in-style-1a924f244ad1
Apache License 2.0
695 stars 36 forks source link

Catalyst track scrollWheel with NSApp.publisher(for: \.currentEvent) #22

Open andriiicatmed opened 3 years ago

andriiicatmed commented 3 years ago

This is the code I use for tracking scrollWheel:

NSApp.publisher(for: \.currentEvent)
            .filter { event in event?.type == .scrollWheel }
            .throttle(for: .milliseconds(1), scheduler: DispatchQueue.main, latest: true)
            .sink {  event in
                guard let event = event else {
                    return
                }

            }
            .store(in: &bag)

for catalyst I've tried smth like that: Dynamic.NSApp.publisher(for: \Dynamic.NSApplication.currentEvent).sink { v in gives error Segmentation fault: 11

or like that:

Dynamic.NSApp.publisher(for: \NSApplication.currentEvent).sink { v in gives 'currentEvent' is unavailable in Mac Catalyst