The tutorial now includes how to handle the tab key from within the NSTextEditor.
Took a peek right now and have to say: Well done!
Thank You, and thank you for your feedback on the tutorial. I’ll release it soon.
Hi Sam. I finally had a relatively good-enough migraine day to go through your tutorial. Very nice! It gave me a lot to think about when I adapt my iOS apps to macOS.
Everything went smoothly except for one problem. The horizontal splitter did not function. I could not get it to change position when I tried to drag it. To determine if this was just due to an error on my part while typing in your code, I also tried it with your completed project, and the same thing happened there too. I’m running Sequoia 15.4 and using Xcode 16.3.
Thank you for taking your time to try my tutorial, I’ll try the project in macOS 15 and a newer Xcode tomorrow.
I’ve tried it in 15.2 and it worked. I’m now updating to 15.5 (doesn’t offer me 15.4), and see from there.
Do you see the cursor change when you mouse over?
No, the cursor doesn’t change.
Okay, lets try something.
In the HSplitterView
struct of “ContentView.swift”, lets make the custom splitter use a solid color.
Replace the line
.fill( .gray.opacity(0.0) )
with the line
.fill( .red )
This should make a red line appear in the preview and the running application. If you then mouse over that line, does the cursor change?
uh… shouldnt that be .gray.opacity(255.0)
You’ve found the problem! When the opacity is 0.0, the splitter can’t be seen or interacted with. When I change the opacity to 255.0, the splitter shows up and works correctly.
According to the docs the range is 1.0 to 0.0
Which is most odd, because it works here with opacity of 0.0 on macOS 13, 15.2 and 15.5.
There must be something we’re not aware of that causes it to fail when it’s 100% transparent, would you mind trying an opacity of 0.1 and seeing it still works for you?
Now I’m confused too. The splitter worked fine when the opacity was 0.1. Then I tried again with an opacity of 0.0. This time it worked! I hadn’t cleared the derived data folder between the two compilations, so I don’t know why it would suddenly work now. Even so, you at least now know that your project runs correctly.
Thank you for taking the time to try with the different opacities and report back your findings back to me. Norman had an issue with the Markdown rendering that went away by itself. It seems like there might be some weirdness somewhere and it makes me a bit nervous about writing SwiftUI tutorials.
Glad to help.
By the way, I’m almost done with my second Swift/SwiftUI app, also translated from Xojo. All that remains, aside from ensuring that the app looks right on all the available iPad sizes, is adding a custom icon for the saved data files, but I haven’t been able to find any documentation about the required icon size in the developer documentation or the UI guidelines.