Open
Conversation
Allow WKWebView to become first responder and use the view-based preview path instead of the data-based path. This enables keyboard shortcuts including Cmd+C to work in the Quick Look preview. Previously, MyWKWebView explicitly returned false for canBecomeKeyView and becomeFirstResponder, which blocked all keyboard input. Additionally, with QLIsDataBasedPreview=true, macOS 12+ used the providePreview method which doesn't use the WKWebView at all, giving us no control over keyboard handling. By setting QLIsDataBasedPreview=false and allowing the WebView to become first responder, Quick Look now uses preparePreviewOfFile with our WKWebView, and Cmd+C works correctly. Fixes sbarex#177
Owner
|
On my system (Tahoe 26.2), the Cmd+C shortcut works correctly! So it seems that the problem must be sought elsewhere… Setting For this reason, I don't want to change this setting. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #177
Problem
Cmd+C doesn't work in Quick Look preview on macOS Tahoe 26.2+, while right-click copy works fine.
Root Cause
Two issues combined to prevent keyboard input:
MyWKWebViewexplicitly blocked keyboard focus by returningfalseforcanBecomeKeyViewandbecomeFirstResponderQLIsDataBasedPreview=true, macOS 12+ uses theprovidePreviewmethod which bypasses our WKWebView entirely, giving us no control over keyboard handlingFix
MyWKWebViewto become first responderQLIsDataBasedPreview=falseto use thepreparePreviewOfFilecode path where our WKWebView handles the previewTesting
Changes
QLExtension/PreviewViewController.swift:MyWKWebViewnow returnstrueforcanBecomeKeyViewandbecomeFirstResponderQLExtension/Info.plist:QLIsDataBasedPreviewset tofalse