<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/detecting-the-focused-window-on-macos-in-swiftui-fbhwv7mrw" -->

---
title: Detecting the focused window on macOS in SwiftUI | daily.dev
description: The `controlActiveState` environment value for detecting window focus in SwiftUI on macOS has been deprecated since macOS 15. The replacement is...
canonical: https://daily.dev/posts/detecting-the-focused-window-on-macos-in-swiftui-fbhwv7mrw
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Detecting the focused window on macOS in SwiftUI | daily.dev
og:description: The `controlActiveState` environment value for detecting window focus in SwiftUI on macOS has been deprecated since macOS 15. The replacement is...
og:url: https://daily.dev/posts/detecting-the-focused-window-on-macos-in-swiftui-fbhwv7mrw
og:image: https://api.daily.dev/og/posts/FbHWV7mrw.png
og:image:alt: Detecting the focused window on macOS in SwiftUI
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Detecting the focused window on macOS in SwiftUI

**[Nil Coalescing](https://daily.dev/sources/nilcoalescing)** · 1 min read · 0 upvotes · 0 comments

## Summary

The `controlActiveState` environment value for detecting window focus in SwiftUI on macOS has been deprecated since macOS 15. The replacement is `appearsActive`, a boolean environment value that is `true` when the window is focused and `false` otherwise. A code example shows how to read this value and react to focus changes using `onChange`, useful for adjusting UI appearance or triggering actions when a window becomes inactive.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://nilcoalescing.com/blog/DetectFocusedWindowOnMacOS>

## Similar posts on daily.dev

- [SwiftUI FocusState: A Little Pitfall I Fall Into](https://daily.dev/posts/swiftui-focusstate-a-little-pitfall-i-fall-into-zupik4ecv) · gitconnected · 0 upvotes · 0 comments
- [Using SwiftUI to Build a Mac-assed App in 2026](https://daily.dev/posts/using-swiftui-to-build-a-mac-assed-app-in-2026-osppvd4pe) · Lobsters · 2 upvotes · 0 comments
- [How native SwiftUI controls look different in iOS 26](https://daily.dev/posts/how-native-swiftui-controls-look-different-in-ios-26-abwxnqlub) · Sarunw · 1 upvotes · 0 comments
- [SwiftUI data dependencies and their effect on view updates](https://daily.dev/posts/swiftui-data-dependencies-and-their-effect-on-view-updates-2kp42i6if) · Nil Coalescing · 1 upvotes · 0 comments

---

Tags: [#swift](https://daily.dev/tags/swift), [#mac](https://daily.dev/tags/mac), [#swiftui](https://daily.dev/tags/swiftui)

[View this post on daily.dev](https://daily.dev/posts/detecting-the-focused-window-on-macos-in-swiftui-fbhwv7mrw)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Detecting the focused window on macOS in SwiftUI","url":"https://daily.dev/posts/detecting-the-focused-window-on-macos-in-swiftui-fbhwv7mrw","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/detecting-the-focused-window-on-macos-in-swiftui-fbhwv7mrw"},"datePublished":"2026-08-02T07:15:14.768Z","dateModified":"2026-08-24T07:01:55.335Z","description":"The `controlActiveState` environment value for detecting window focus in SwiftUI on macOS has been deprecated since macOS 15. The replacement is...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/d721d6db4d4270f8a57a877156c89ccd?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/d721d6db4d4270f8a57a877156c89ccd?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Nil Coalescing","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Nil Coalescing","logo":"https://media.daily.dev/image/upload/s--rcEu6sag--/f_auto,q_auto/v1785654899/logos/nilcoalescing?_a=BAMAMicg0","url":"https://daily.dev/sources/nilcoalescing"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/detecting-the-focused-window-on-macos-in-swiftui-fbhwv7mrw","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"swift,mac,swiftui","timeRequired":"PT1M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Nil Coalescing","item":"https://daily.dev/sources/nilcoalescing"},{"@type":"ListItem","position":3,"name":"Detecting the focused window on macOS in SwiftUI"}]}
```

