Skip to content

Commit

Permalink
Merge pull request #1795 from barijaona/issue-1793
Browse files Browse the repository at this point in the history
Do not intercept characters typed into input boxes
  • Loading branch information
barijaona authored Aug 26, 2024
2 parents 4591504 + 7e635ab commit 829f03e
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion Vienna/Sources/Main window/WebKitArticleView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,19 @@ class WebKitArticleView: CustomWKWebView, ArticleContentView, WKNavigationDelega

/// handle special keys when the article view has the focus
override func keyDown(with event: NSEvent) {
if let pressedKeys = event.characters, pressedKeys.count == 1 {
var interceptKey = true
waitForAsyncExecution(until: DispatchTime.now() + DispatchTimeInterval.milliseconds(200)) { finishHandler in
self.evaluateJavaScript("document.activeElement.tagName") { res, _ in
guard let res = res as? String else {
return
}
if ["INPUT", "TEXTAREA"].contains(res) {
interceptKey = false
}
finishHandler()
}
}
if interceptKey, let pressedKeys = event.characters, pressedKeys.count == 1 {
let pressedKey = (pressedKeys as NSString).character(at: 0)
// give app controller preference when handling commands
if NSApp.appController.handleKeyDown(pressedKey, withFlags: event.modifierFlags.rawValue) {
Expand Down

0 comments on commit 829f03e

Please sign in to comment.