Posts

Post not yet marked as solved
0 Replies
229 Views
I'm working on a program where I need a custom magnification gesture that takes account of X and Y magnification separately, preventing me from using the stock MagnificationGesture supplied with SwiftUI. I'm using a custom NSViewController containing a custom NSView that receives and interprets touch events itself, implementing the behavior I want. The NSViewController is turned into a SwiftUI View using an NSViewControllerRepresentable and placed into a ContentView hierarchy, and this is all working fine except when I instantiate some additional controls (some checkboxes or sliders, for example) elsewhere in the ContentView, at which point the touch events no longer get received and processed by my custom NSView in a timely manner. It's as if a gesture recognizer is hogging all of the touch events and preventing them from reaching my custom NSView. Any idea how I can force the system to continue to send all touch events to my NSView when they occur within it? I might consider creating a custom subclass of Gesture to implement my special x-y magnifier, but it's not at all clear how to do that from the documentation for Gesture. How does a Gesture receive touch events to process? Suggestions? Or do I need to abandon SwiftUI for the time being and go back to using a storyboard?
Posted
by DEMandell.
Last updated
.
Post not yet marked as solved
1 Replies
454 Views
I just ported components (NSView and NSViewController subclasses) of an older Objective-C program to Swift and created an application using SwiftUI, and although I have it all working functionally, antialiasing has been turned off and everything looks much worse than essentially the same code running in the older program. How can I turn antialiasing back on in a SwiftUI View? I tried: NSGraphicsContext.current?.shouldAntialias = true down in the code that actually does the drawing, but it has no effect. Numerous searches for antialiasing in conjunction with SwiftUI turned up pretty much nothing. I would love to get my program looking smooth and pretty again!
Posted
by DEMandell.
Last updated
.
Post not yet marked as solved
1 Replies
618 Views
I have parts of an old Mac app, originally written in Objective-C, that I would like to pull into a new Mac app, hopefully written in Swift and using SwiftUI. I understand that somehow I need to use NSViewRepresentable and NSViewControllerRepresentable, creating View objects that conform to these protocols, but it's entirely unclear how to instantiate my custom NSView and NSViewController subclasses and connect them into the app using SwiftUI. This was originally done with Interface Builder. I have spent several hours so far searching on the web for any examples or other help, but have found very little. Somehow I expected to find others who also wanted to reuse perfectly good custom views and controllers in new apps using SwiftUI! All help gratefully appreciated.
Posted
by DEMandell.
Last updated
.