From 7764b92788ff470eb05d5a2a1b9a01befbeb04df Mon Sep 17 00:00:00 2001 From: Russell Keith-Magee Date: Mon, 4 Sep 2023 06:58:09 +0800 Subject: [PATCH 1/3] Enable webkit inspector for iOS and Cococa. --- cocoa/src/toga_cocoa/widgets/webview.py | 8 ++++++++ docs/reference/api/widgets/webview.rst | 14 +++++++++----- iOS/src/toga_iOS/widgets/webview.py | 4 ++++ 3 files changed, 21 insertions(+), 5 deletions(-) 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/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 From c74d2ba50e853d2fe2eea5e5f49560571bceacce Mon Sep 17 00:00:00 2001 From: Russell Keith-Magee Date: Mon, 4 Sep 2023 07:02:00 +0800 Subject: [PATCH 2/3] Add changenote. --- changes/2109.feature.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 changes/2109.feature.rst 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. From fefaddd8c213256f0d58b66cc6c1e37764584310 Mon Sep 17 00:00:00 2001 From: Russell Keith-Magee Date: Mon, 4 Sep 2023 07:06:40 +0800 Subject: [PATCH 3/3] Add Ventura to dictionary. --- docs/spelling_wordlist | 1 + 1 file changed, 1 insertion(+) 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