1
0
mirror of https://github.com/Toxblh/MTMR.git synced 2026-01-10 17:08:39 +00:00

Merge pull request #55 from ad/master

deinit inputsource observer, button highlight on touch
This commit is contained in:
Anton Palgunov 2018-04-29 23:00:07 +01:00 committed by GitHub
commit d37d9607d3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 21 additions and 3 deletions

View File

@ -27,6 +27,7 @@ class CustomButtonTouchBarItem: NSCustomTouchBarItem, NSGestureRecognizerDelegat
button.cell?.title = title
button.title = title
button.bezelStyle = .rounded
button.bezelColor = bezelColor
self.view = button
@ -91,13 +92,21 @@ class CustomButtonCell: NSButtonCell {
super.init(textCell: "")
if backgroundColor != .clear {
self.isBordered = true
self.bezelStyle = .rounded
self.backgroundColor = backgroundColor
} else {
self.isBordered = false
}
}
override func highlight(_ flag: Bool, withFrame cellFrame: NSRect, in controlView: NSView) {
if flag {
self.isBordered = true
} else {
self.isBordered = false
}
super.highlight(flag, withFrame: cellFrame, in: controlView)
}
required init(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

View File

@ -26,8 +26,12 @@
<true/>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2018 Anton Palgunov. All rights reserved.</string>
<key>NSLocationAlwaysUsageDescription</key>
<string>Weather widget need your location for correct work</string>
<key>NSLocationUsageDescription</key>
<string>...</string>
<string>Weather widget need your location for correct work</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>Weather widget need your location for correct work</string>
<key>NSMainStoryboardFile</key>
<string>Main</string>
<key>NSPrincipalClass</key>

View File

@ -10,7 +10,7 @@ class ScrollViewItem: NSCustomTouchBarItem {
stackView.orientation = .horizontal
let scrollView = NSScrollView(frame: CGRect(origin: .zero, size: stackView.fittingSize))
scrollView.documentView = stackView
scrollView.documentView?.bounds.origin = CGPoint(x: 0.0, y: -2.5)
// scrollView.documentView?.bounds.origin = CGPoint(x: 0.0, y: -2.5)
self.view = scrollView
}

View File

@ -215,6 +215,7 @@ class TouchBarController: NSObject, NSTouchBarDelegate {
let button = item.button!
button.imageScaling = .scaleProportionallyDown
button.imagePosition = .imageLeading
button.imageHugsTitle = true
button.cell?.image = source.image
button.bezelColor = .clear
}

View File

@ -31,6 +31,10 @@ class InputSourceBarItem: CustomButtonTouchBarItem {
fatalError("init(coder:) has not been implemented")
}
deinit {
CFNotificationCenterRemoveEveryObserver(notificationCenter, UnsafeRawPointer(Unmanaged.passUnretained(self).toOpaque()));
}
@objc override func handleGestureSingle(gr: NSClickGestureRecognizer) {
super.handleGestureSingle(gr: gr)
switchInputSource()