forked from sbarex/SourceCodeSyntaxHighlight
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSaveAsFormatView.swift
More file actions
38 lines (31 loc) · 1 KB
/
Copy pathSaveAsFormatView.swift
File metadata and controls
38 lines (31 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
//
// SaveAsFormatView.swift
// Syntax Highlight
//
// Created by Sbarex on 18/12/20.
//
import Cocoa
class SaveAsFormatView: NSView {
@IBOutlet weak var popupButton: NSPopUpButton!
@IBOutlet weak var contentView: NSView!
weak var savePanel: NSSavePanel?
override init(frame frameRect: NSRect) {
super.init(frame: frameRect)
setup()
}
required init?(coder decoder: NSCoder) {
super.init(coder: decoder)
setup()
}
private func setup() {
let bundle = Bundle(for: type(of: self))
let nib = NSNib(nibNamed: .init(String(describing: type(of: self))), bundle: bundle)!
nib.instantiate(withOwner: self, topLevelObjects: nil)
addSubview(contentView)
contentView.frame = self.bounds
contentView.autoresizingMask = [.width, .height]
}
@IBAction func formatChange(_ sender: NSPopUpButton) {
savePanel?.allowedFileTypes = [sender.indexOfSelectedItem == 0 ? "theme" : "css"]
}
}