macos-auto-clicker
macos-auto-clicker copied to clipboard
The number fields are really glitchy
Description
Its been a problem since the apps inception, but as SwiftUI doesn't have a numeric only field, you have to fudge the TextField with support which is what this app has been running on.
However, this has changed somewhat since this app was first made and there are better ways to handle updates:
https://www.hackingwithswift.com/quick-start/swiftui/how-to-format-a-textfield-for-numbers
I need to review the fields and make support better as at the moment, they're glitchy as anything. Especially when trying to change the field from something like 1 to 5 seconds as you can never remove the 1 as it won't let you empty the field.
Version
latest
Steps to Reproduce
See description.
Screenshots
No response
Device
Any Mac
Operating System
macOS 13.x
Additional Context
No response
Any specific approach you've wanted to integrate this? I may create a PR.
Oh nice! Yeah that'd be good. Nothing specific, UI wise I'd want them to appear the same. The main issue is that at the moment they are Text fields with fudgy reactive validation, but that causes things to behave weirdly. Since making this app, there are far better ways now available in Swift UI to natively do what I had to do hackily at the time. A nice refactor is on the cards:
https://www.hackingwithswift.com/quick-start/swiftui/how-to-format-a-textfield-for-numbers
Its mainly so in the use case of say having the field filled with 1, it won't let you empty the field to then enter 5 as the realtime validation won't allow the field to be empty.
It needs to not be empty on start, so the validation trigger could be moved I guess. But the main thing is to just try to make them feel less finicky and more reliable with what you'd expect with something like a HTML Number field. As at the time of making this app, there wasn't a native Number field in Swift UI that only allowed numbers to be entered.
Okay perfect, i'll try to read and look into this next week.
Quick Question, is there a reason why the validation is called twice? once in DynamicNumberField and once in NumberField.
It's so long ago, honestly no idea. Could be an abstraction artifact. Could be a bug!
I can't believe after all this time, SwiftUI still doesn't have an at-point-of-entry validation system for blocking non-alpha text input on macOS.