diff --git a/changes/2109.feature.rst b/changes/2109.feature.rst new file mode 100644 index 0000000000..5d1a07e596 --- /dev/null +++ b/changes/2109.feature.rst @@ -0,0 +1 @@ +The WebKit inspector is automatically enabled on all webviews, provided you're using macOS 13.3 (Ventura) or iOS 16.4, or later. diff --git a/cocoa/src/toga_cocoa/widgets/webview.py b/cocoa/src/toga_cocoa/widgets/webview.py index 4e9431d07d..c0f7c117ca 100644 --- a/cocoa/src/toga_cocoa/widgets/webview.py +++ b/cocoa/src/toga_cocoa/widgets/webview.py @@ -48,6 +48,14 @@ def create(self): self.native.interface = self.interface self.native.impl = self + # Enable the content inspector. This was added in macOS 13.3 (Ventura). It will + # be a no-op on newer versions of macOS; you need to package the app, then run: + # + # defaults write com.example.appname WebKitDeveloperExtras -bool true + # + # from the command line. + self.native.inspectable = True + self.native.navigationDelegate = self.native self.native.uIDelegate = self.native diff --git a/docs/reference/api/widgets/webview.rst b/docs/reference/api/widgets/webview.rst index a020b9e363..9068d912ba 100644 --- a/docs/reference/api/widgets/webview.rst +++ b/docs/reference/api/widgets/webview.rst @@ -46,16 +46,20 @@ Notes * Using WebView on Linux requires that the user has installed the system packages for WebKit2, plus the GObject Introspection bindings for WebKit2. -* On macOS, the "inspect element" feature is not enabled by default. WebView - debugging is only available when your code is packaged as a full macOS app - (e.g., with Briefcase). To enable debugging, run: +* On macOS 13.3 (Ventura) and later, the content inspector for your app can be opened by + running Safari, `enabling the developer tools + `__, and selecting your + app's window from the "Develop" menu. + + On macOS versions prior to Ventura, the content inspector is not enabled by default, + and is only available when your code is packaged as a full macOS app (e.g., with + Briefcase). To enable debugging, run: .. code-block:: console $ defaults write com.example.appname WebKitDeveloperExtras -bool true - Substituting ``com.example.appname`` with the bundle ID for your packaged - app. + Substituting ``com.example.appname`` with the bundle ID for your packaged app. Reference --------- diff --git a/docs/spelling_wordlist b/docs/spelling_wordlist index afd9e49146..4f678adb31 100644 --- a/docs/spelling_wordlist +++ b/docs/spelling_wordlist @@ -79,6 +79,7 @@ tvOS Ubuntu validator validators +Ventura verbing viewport watchOS diff --git a/iOS/src/toga_iOS/widgets/webview.py b/iOS/src/toga_iOS/widgets/webview.py index 2181e7a794..2dfc08c14b 100644 --- a/iOS/src/toga_iOS/widgets/webview.py +++ b/iOS/src/toga_iOS/widgets/webview.py @@ -43,6 +43,10 @@ def create(self): self.native.interface = self.interface self.native.impl = self + # Enable the content inspector. This was added in iOS 16.4. + # It is a no-op on earlier versions. + self.native.inspectable = True + self.native.navigationDelegate = self.native self.native.uIDelegate = self.native