A small menubar app that allows you to switch between R versions quickly (if you have multiple versions of R framework installed). https://rud.is/rswitch
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

94 lines
2.0 KiB

3 years ago
//
// plotPopupViewController.swift
// wktest
//
// Created by hrbrmstr on 9/9/19.
// Copyright © 2019 Bob Rudis. All rights reserved.
//
import Cocoa
import WebKit
class plotPopupViewController: NSViewController {
var webView: WKWebView!
var urlPath: String = ""
open override func viewDidLoad() {
super.viewDidLoad()
}
func setupWebView(configuration: WKWebViewConfiguration) {
webView = WKWebView(frame: view.bounds, configuration: configuration)
webView.autoresizingMask = [.width, .height]
webView.uiDelegate = self
webView.navigationDelegate = self
view.addSubview(webView)
}
2 years ago
3 years ago
func loadWebView(urlIn: String) {
urlPath = urlIn
2 years ago
NSLog(urlPath)
// Check for "/export/"
// If export, then get bring up a Save Panel and then download the file to that location
3 years ago
if let url = URL(string: urlPath) {
let urlRequest = URLRequest(url: url)
webView.load(urlRequest)
}
}
override func viewDidAppear() {
super.viewDidAppear()
}
}
extension plotPopupViewController: WKUIDelegate {
func webViewDidClose(_ webView: WKWebView) {
self.view.window?.close()
}
2 years ago
func webView(_ webView: WKWebView, runOpenPanelWith parameters: WKOpenPanelParameters, initiatedByFrame frame: WKFrameInfo, completionHandler: @escaping ([URL]?) -> Void) {
NSLog("savePanel!")
let savePanel = NSSavePanel()
savePanel.canCreateDirectories = true
savePanel.beginSheetModal(for:self.view.window!) { (response) in
if (response == NSApplication.ModalResponse.OK) {
completionHandler([savePanel.url!])
} else {
completionHandler(nil)
}
savePanel.close()
}
}
3 years ago
}
extension plotPopupViewController: WKNavigationDelegate {
2 years ago
3 years ago
open func webView(_ webView: WKWebView, didStartProvisionalNavigation navigation: WKNavigation!) {
2 years ago
print("DID START")
3 years ago
}
2 years ago
3 years ago
func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
2 years ago
print("DID FINISH")
3 years ago
}
2 years ago
3 years ago
}
2 years ago