Fix touch bar icon state

This commit is contained in:
1024jp 2017-01-13 19:28:59 +09:00
parent 1d89643420
commit f4ff321d44
3 changed files with 31 additions and 12 deletions

View File

@ -27,7 +27,8 @@ develop
- Fix an issue where the application could crash after lossy encoding change.
- Fix an issue where the find string was not synchronized with other applications.
- Fix an issue where incompatible characters highlight could highlight wrong characters if line endings are CR/LF.
- Fix an issue the menu item “About Scripting” in Help > “CotEditor Scripting Manual” didn't work.
- Fix an issue where some touch bar icons were drawn wrongly.
- Fix an issue where the menu item “About Scripting” in Help > “CotEditor Scripting Manual” didn't work.
- Fix an issue where the zoomed character in the character inspector was flipped when the popover is detached.
- Fix an issue where `lossy` option in `convert` command by AppleScript scripting was ignored.
- Fix an issue on the AppleScript scripting where `range` property of `document` contents could be wrong if document line endings are not LF. (thanks to Kaito Udagawa!).

View File

@ -9,7 +9,7 @@
------------------------------------------------------------------------------
© 2016 1024jp
© 2016-2017 1024jp
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@ -70,13 +70,13 @@ extension DocumentViewController: NSTouchBarDelegate {
case NSTouchBarItemIdentifier.invisibles:
let item = NSCustomTouchBarItem(identifier: identifier)
item.customizationLabel = NSLocalizedString("Invisibles", comment: "touch bar item")
item.view = NSButton(image: #imageLiteral(resourceName: "InvisiblesTemplate"), target: self, action: #selector(toggleInvisibleChars(_:)))
item.view = NSButton(image: #imageLiteral(resourceName: "InvisiblesTemplate"), target: self, action: #selector(toggleInvisibleCharsViaTouchBar(_:)))
return item
case NSTouchBarItemIdentifier.wrapLines:
let item = NSCustomTouchBarItem(identifier: identifier)
item.customizationLabel = NSLocalizedString("Wrap Lines", comment: "touch bar item")
item.view = NSButton(image: #imageLiteral(resourceName: "WrapLinesTemplate"), target: self, action: #selector(toggleLineWrap(_:)))
item.view = NSButton(image: #imageLiteral(resourceName: "WrapLinesTemplate"), target: self, action: #selector(toggleLineWrapViaTouchBar(_:)))
return item
case NSTouchBarItemIdentifier.share:
@ -92,6 +92,30 @@ extension DocumentViewController: NSTouchBarDelegate {
}
}
/// toggle visibility of invisible characters in text view
@IBAction private func toggleInvisibleCharsViaTouchBar(_ sender: NSButton) {
self.toggleInvisibleChars(sender)
// update UI manually
// -> workaround for the issue where UI doesn't update on a touch bar event (2017-01 macOS 10.12.2 SDK)
self.view.window?.toolbar?.validateVisibleItems()
self.touchBar?.validateVisibleItems()
}
/// toggle if lines wrap at window edge
@IBAction private func toggleLineWrapViaTouchBar(_ sender: NSButton) {
self.toggleLineWrap(sender)
// update UI manually
// -> workaround for the issue where UI doesn't update on a touch bar event (2017-01 macOS 10.12.2 SDK)
self.view.window?.toolbar?.validateVisibleItems()
self.touchBar?.validateVisibleItems()
}
}
@ -114,7 +138,7 @@ extension DocumentViewController: TouchBarItemValidations {
}
}() else { return true }
let color: NSColor? = isEnabled ? nil : .quaternaryLabelColor
let color: NSColor? = isEnabled ? nil : NSColor(white: 0.15, alpha: 1)
if button.bezelColor != color {
button.bezelColor = color
button.needsDisplay = true

View File

@ -10,7 +10,7 @@
------------------------------------------------------------------------------
© 2004-2007 nakamuxu
© 2014-2016 1024jp
© 2014-2017 1024jp
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@ -543,9 +543,6 @@ final class DocumentViewController: NSSplitViewController, SyntaxStyleDelegate,
@IBAction func toggleLineWrap(_ sender: Any?) {
self.wrapsLines = !self.wrapsLines
// workaround for change via touch bar (2016-11 macOS 10.12.1 SDK)
self.view.window?.toolbar?.validateVisibleItems()
}
@ -571,9 +568,6 @@ final class DocumentViewController: NSSplitViewController, SyntaxStyleDelegate,
@IBAction func toggleInvisibleChars(_ sender: Any?) {
self.showsInvisibles = !self.showsInvisibles
// workaround for change via touch bar (2016-11 macOS 10.12.1 SDK)
self.view.window?.toolbar?.validateVisibleItems()
}