mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-16 16:56:09 +03:00
Merge pull request #1863 from robbiev/fix-macos-inspector-focus
macos: regain window focus on inspector toggle
This commit is contained in:
@ -37,6 +37,19 @@ extension Ghostty {
|
||||
}
|
||||
}
|
||||
.onReceive(pubInspector) { onControlInspector($0) }
|
||||
.onChange(of: surfaceView.inspectorVisible) { inspectorVisible in
|
||||
// When we show the inspector, we want to focus on the inspector.
|
||||
// When we hide the inspector, we want to move focus back to the surface.
|
||||
if (inspectorVisible) {
|
||||
// We need to delay this until SwiftUI shows the inspector.
|
||||
DispatchQueue.main.async {
|
||||
_ = surfaceView.resignFirstResponder()
|
||||
inspectorFocus = true
|
||||
}
|
||||
} else {
|
||||
Ghostty.moveFocus(to: surfaceView)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private func onControlInspector(_ notification: SwiftUI.Notification) {
|
||||
@ -57,18 +70,6 @@ extension Ghostty {
|
||||
default:
|
||||
return
|
||||
}
|
||||
|
||||
// When we show the inspector, we want to focus on the inspector.
|
||||
// When we hide the inspector, we want to move focus back to the surface.
|
||||
if (surfaceView.inspectorVisible) {
|
||||
// We need to delay this until SwiftUI shows the inspector.
|
||||
DispatchQueue.main.async {
|
||||
_ = surfaceView.resignFirstResponder()
|
||||
inspectorFocus = true
|
||||
}
|
||||
} else {
|
||||
Ghostty.moveFocus(to: surfaceView)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user