UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

TextField, .disabled(), and macOS

Forums > SwiftUI

I'm writing an application for macOS using SwiftUI and I want to allow the user to set some values for the app to use when it does work, but not to change those values if the app is currently working.

I've found that the .disabled() modifier works fine for buttons (disabling the Start button when it's already going, and disabling the Stop button when it's already stopped) but that it doesn't work for TextField. The TextField doesn't get disabled and, furthermore, there are a bunch of messages spewed to the log like:

AttributeGraph: cycle detected through attribute <##>

This is targeting 10.15, so maybe it gets fixed in Big Sur. But, you know, FYI.

2      

Tried it on macOS 11.1 and works fine.

3      

Cool! Okay, so that's one more in the column for upgrading.

2      

BUILD THE ULTIMATE PORTFOLIO APP Most Swift tutorials help you solve one specific problem, but in my Ultimate Portfolio App series I show you how to get all the best practices into a single app: architecture, testing, performance, accessibility, localization, project organization, and so much more, all while building a SwiftUI app that works on iOS, macOS and watchOS.

Get it on Hacking with Swift+

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.