Last active
May 3, 2018 16:58
-
-
Save jhoughjr/68f42e47a1104ce8ac8d837d0024cac5 to your computer and use it in GitHub Desktop.
This file contains 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
func focusEditor() { | |
let loc = CGPoint(x: (textView!.frame.origin.x + (textView!.frame.size.width / 2)), | |
y: (textView!.frame.origin.y + (textView!.frame.size.height / 2))) | |
let realLoc = textView!.convert(loc, | |
to: nil) | |
let e = NSEvent.mouseEvent(with: .leftMouseDown, | |
location: realLoc, | |
modifierFlags: [], | |
timestamp:ProcessInfo.processInfo.systemUptime , | |
windowNumber: textView!.window!.windowNumber, | |
context: nil, | |
eventNumber: 0, | |
clickCount: 1, | |
pressure: 0.0) | |
textView?.mouseDown(with: e!) | |
// let f = WKUserScript(source: "quill.focus();", | |
// injectionTime: .atDocumentEnd, | |
// forMainFrameOnly: false) | |
// textView?.evaluateJavaScript(f.source, | |
// completionHandler: { (obj, err) in | |
// SwiftyBeaver.debug("focued") | |
// }) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
(lldb) po err!
Error Domain=WKErrorDomain Code=4 "A JavaScript exception occurred" UserInfo={WKJavaScriptExceptionLineNumber=1, WKJavaScriptExceptionMessage=TypeError: null is not an object (evaluating 'document.getElementById('editor').click'), WKJavaScriptExceptionColumnNumber=34, WKJavaScriptExceptionSourceURL=undefined, NSLocalizedDescription=A JavaScript exception occurred}