I'm making a macOS app with SwiftUI, in which I want to use the arrow keys to offset a Circle view. The only problem I have is that my Circle view is surrounded by a blue focus ring, which I would like to remove, but don't know how. Other than that, my code works fine. (see the image below, I'd like to remove the blue border)
I've found many questions on Stack Overflow about removing the focus ring from a TextField, but not for other types of views. How do I remove the focus ring from an non-TextField view using SwiftUI? If it isn't possible to do so, how else can I achieve the same functionality without the focus ring?
Code:
struct UITestbed: View {
@State private var xInput: CGFloat = 0
@State private var yInput: CGFloat = 0
var body: some View {
Circle()
.frame(width: 20, height: 20)
.focusable()
.offset(x: self.xInput, y: self.yInput)
.onMoveCommand { (direction) in
withAnimation(.easeInOut) {
switch direction {
case .right:
self.xInput += 10
case .left:
self.xInput -= 10
case .up:
self.yInput -= 10
case .down:
self.yInput += 10
default:
fatalError("Unknown move command")
}
}}
}
}
