Create WebViewWindow, which holds a WKWebView. To be used for keyboard shortcuts and whatever else needs a plain web view in a window.

This commit is contained in:
Brent Simmons 2017-11-13 13:23:22 -08:00
parent 00ff9016bc
commit 773f660601
4 changed files with 85 additions and 5 deletions

View File

@ -82,6 +82,8 @@
845DE0F31B80477100D1571B /* NSSet+RSCore.h in Headers */ = {isa = PBXBuildFile; fileRef = 845DE0F11B80477100D1571B /* NSSet+RSCore.h */; settings = {ATTRIBUTES = (Public, ); }; };
845DE0F41B80477100D1571B /* NSSet+RSCore.m in Sources */ = {isa = PBXBuildFile; fileRef = 845DE0F21B80477100D1571B /* NSSet+RSCore.m */; };
8461387F1DB3F5BE00048B83 /* RSToolbarItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8461387E1DB3F5BE00048B83 /* RSToolbarItem.swift */; };
8479213C1FBA426B004AD08C /* WebViewWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = 8479213B1FBA426B004AD08C /* WebViewWindow.xib */; };
8479213E1FBA4285004AD08C /* WebViewWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8479213D1FBA4285004AD08C /* WebViewWindowController.swift */; };
849A339D1AC90A0A0015BA09 /* NSTableView+RSCore.h in Headers */ = {isa = PBXBuildFile; fileRef = 849A339B1AC90A0A0015BA09 /* NSTableView+RSCore.h */; settings = {ATTRIBUTES = (Public, ); }; };
849A339E1AC90A0A0015BA09 /* NSTableView+RSCore.m in Sources */ = {isa = PBXBuildFile; fileRef = 849A339C1AC90A0A0015BA09 /* NSTableView+RSCore.m */; };
849B08971BF7BCE30090CEE4 /* NSPasteboard+RSCore.h in Headers */ = {isa = PBXBuildFile; fileRef = 849B08951BF7BCE30090CEE4 /* NSPasteboard+RSCore.h */; settings = {ATTRIBUTES = (Public, ); }; };
@ -184,6 +186,8 @@
845DE0F11B80477100D1571B /* NSSet+RSCore.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSSet+RSCore.h"; sourceTree = "<group>"; };
845DE0F21B80477100D1571B /* NSSet+RSCore.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSSet+RSCore.m"; sourceTree = "<group>"; };
8461387E1DB3F5BE00048B83 /* RSToolbarItem.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RSToolbarItem.swift; sourceTree = "<group>"; };
8479213B1FBA426B004AD08C /* WebViewWindow.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = WebViewWindow.xib; path = AppKit/WebViewWindow.xib; sourceTree = "<group>"; };
8479213D1FBA4285004AD08C /* WebViewWindowController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = WebViewWindowController.swift; path = AppKit/WebViewWindowController.swift; sourceTree = "<group>"; };
849A339B1AC90A0A0015BA09 /* NSTableView+RSCore.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSTableView+RSCore.h"; sourceTree = "<group>"; };
849A339C1AC90A0A0015BA09 /* NSTableView+RSCore.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSTableView+RSCore.m"; sourceTree = "<group>"; };
849B08951BF7BCE30090CEE4 /* NSPasteboard+RSCore.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSPasteboard+RSCore.h"; sourceTree = "<group>"; };
@ -420,6 +424,8 @@
8414CBA91C95F8F700333C12 /* RSGeometry.h */,
8414CBAA1C95F8F700333C12 /* RSGeometry.m */,
8461387E1DB3F5BE00048B83 /* RSToolbarItem.swift */,
8479213B1FBA426B004AD08C /* WebViewWindow.xib */,
8479213D1FBA4285004AD08C /* WebViewWindowController.swift */,
842DD7F91E1499FA00E061EB /* Views */,
);
name = AppKit;
@ -626,6 +632,7 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
8479213C1FBA426B004AD08C /* WebViewWindow.xib in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -709,6 +716,7 @@
84CFF5591AC3CF9100CEA6C8 /* NSView+RSCore.m in Sources */,
84CFF56A1AC3D1B000CEA6C8 /* RSScaling.m in Sources */,
84FEB4AC1D19D7F4004727E5 /* Date+Extensions.swift in Sources */,
8479213E1FBA4285004AD08C /* WebViewWindowController.swift in Sources */,
8461387F1DB3F5BE00048B83 /* RSToolbarItem.swift in Sources */,
84B99C941FAE64D500ECDEDB /* DisplayNameProvider.swift in Sources */,
84BB45431D6909C700B48537 /* NSMutableDictionary-Extensions.swift in Sources */,

View File

@ -0,0 +1,45 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="13526" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="13526"/>
<plugIn identifier="com.apple.WebKit2IBPlugin" version="13526"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="WebViewWindowController" customModule="RSCore" customModuleProvider="target">
<connections>
<outlet property="webview" destination="E6W-Ua-YwP" id="dYj-pg-M6n"/>
<outlet property="window" destination="QvC-M9-y7g" id="EnP-ca-jeo"/>
</connections>
</customObject>
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
<window title="Window" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" oneShot="NO" releasedWhenClosed="NO" animationBehavior="default" id="QvC-M9-y7g">
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
<rect key="contentRect" x="206" y="471" width="480" height="270"/>
<rect key="screenRect" x="0.0" y="0.0" width="1440" height="877"/>
<value key="minSize" type="size" width="480" height="270"/>
<value key="maxSize" type="size" width="2048" height="2048"/>
<view key="contentView" wantsLayer="YES" id="EiT-Mj-1SZ">
<rect key="frame" x="0.0" y="0.0" width="480" height="270"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<wkWebView wantsLayer="YES" translatesAutoresizingMaskIntoConstraints="NO" id="E6W-Ua-YwP">
<rect key="frame" x="0.0" y="0.0" width="480" height="270"/>
<wkWebViewConfiguration key="configuration">
<audiovisualMediaTypes key="mediaTypesRequiringUserActionForPlayback" none="YES"/>
<wkPreferences key="preferences"/>
</wkWebViewConfiguration>
</wkWebView>
</subviews>
<constraints>
<constraint firstItem="E6W-Ua-YwP" firstAttribute="top" secondItem="EiT-Mj-1SZ" secondAttribute="top" id="hlG-XK-mDH"/>
<constraint firstAttribute="bottom" secondItem="E6W-Ua-YwP" secondAttribute="bottom" id="q8o-nj-5qj"/>
<constraint firstAttribute="trailing" secondItem="E6W-Ua-YwP" secondAttribute="trailing" id="s2P-HZ-c08"/>
<constraint firstItem="E6W-Ua-YwP" firstAttribute="leading" secondItem="EiT-Mj-1SZ" secondAttribute="leading" id="tcr-Wl-0J1"/>
</constraints>
</view>
</window>
</objects>
</document>

View File

@ -0,0 +1,27 @@
//
// WebViewWindowController.swift
// RSCore
//
// Created by Brent Simmons on 11/13/17.
// Copyright © 2017 Ranchero Software, LLC. All rights reserved.
//
import Cocoa
import WebKit
public final class WebViewWindowController: NSWindowController {
@IBOutlet private var webview: WKWebView!
private var title: String!
public convenience init(title: String) {
self.init(windowNibName: NSNib.Name(rawValue: "WebViewWindow"))
self.title = title
}
public override func windowDidLoad() {
window!.title = title
}
}

View File

@ -6,12 +6,12 @@
</editor> -->
<title>ToDo</title>
<dateCreated>Tue, 12 Sep 2017 20:15:17 GMT</dateCreated>
<expansionState>0,10,12,17,20,21,24,28,34,36,39,43,45,60,65,78,79</expansionState>
<expansionState>12,42,45,60,65,67,78,79</expansionState>
<vertScrollState>0</vertScrollState>
<windowTop>3169</windowTop>
<windowLeft>477</windowLeft>
<windowRight>1209</windowRight>
<windowBottom>3928</windowBottom>
<windowTop>614</windowTop>
<windowLeft>59</windowLeft>
<windowRight>791</windowRight>
<windowBottom>1373</windowBottom>
</head>
<body>
<outline text="App">