Make progress on editing names in the inspectors.

This commit is contained in:
Brent Simmons 2018-01-22 22:01:25 -08:00
parent 2cf0dbd96e
commit b2d3084313
4 changed files with 51 additions and 5 deletions

View File

@ -110,7 +110,14 @@ private extension FeedInspectorViewController {
func updateName() {
nameTextField?.stringValue = feed?.editedName ?? feed?.name ?? ""
guard let nameTextField = nameTextField else {
return
}
let name = feed?.editedName ?? feed?.name ?? ""
if nameTextField.stringValue != name {
nameTextField.stringValue = name
}
}
func updateHomePageURL() {

View File

@ -8,6 +8,7 @@
import AppKit
import Account
import RSCore
final class FolderInspectorViewController: NSViewController, Inspector {
@ -43,6 +44,29 @@ final class FolderInspectorViewController: NSViewController, Inspector {
override func viewDidLoad() {
updateUI()
NotificationCenter.default.addObserver(self, selector: #selector(displayNameDidChange(_:)), name: .DisplayNameDidChange, object: nil)
}
// MARK: Notifications
@objc func displayNameDidChange(_ note: Notification) {
guard let updatedFolder = note.object as? Folder, updatedFolder == folder else {
return
}
updateUI()
}
}
extension FolderInspectorViewController: NSTextFieldDelegate {
override func controlTextDidChange(_ note: Notification) {
guard let folder = folder, let nameTextField = nameTextField else {
return
}
folder.name = nameTextField.stringValue
}
}
@ -64,7 +88,13 @@ private extension FolderInspectorViewController {
func updateUI() {
nameTextField?.stringValue = folder?.nameForDisplay ?? ""
}
guard let nameTextField = nameTextField else {
return
}
let name = folder?.nameForDisplay ?? ""
if nameTextField.stringValue != name {
nameTextField.stringValue = name
}
}
}

View File

@ -155,6 +155,9 @@ Field</string>
<color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
<connections>
<outlet property="delegate" destination="ylq-Dz-pnT" id="30z-5n-OpR"/>
</connections>
</textField>
</subviews>
<constraints>

View File

@ -111,12 +111,18 @@ private extension InspectorWindowController {
func show(_ inspector: InspectorViewController) {
guard let window = window, inspector !== window.contentViewController else {
guard let window = window else {
return
}
let flippedOrigin = window.flippedOrigin
window.contentViewController = inspector
if window.contentViewController != inspector {
window.contentViewController = inspector
window.makeFirstResponder(nil)
}
window.layoutIfNeeded()
if let flippedOrigin = flippedOrigin {
window.setFlippedOriginAdjustingForScreen(flippedOrigin)
}