Make further progress on the rename sheet.

This commit is contained in:
Brent Simmons 2018-02-03 16:05:59 -08:00
parent e7ce12869c
commit a03562eee8
2 changed files with 27 additions and 1 deletions

View File

@ -41,6 +41,9 @@
<color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/> <color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/> <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell> </textFieldCell>
<connections>
<outlet property="delegate" destination="-2" id="5Oi-0v-kuj"/>
</connections>
</textField> </textField>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="RI3-Rg-htY"> <button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="RI3-Rg-htY">
<rect key="frame" x="321" y="13" width="89" height="32"/> <rect key="frame" x="321" y="13" width="89" height="32"/>

View File

@ -16,9 +16,32 @@ final class RenameWindowController: NSWindowController {
private var originalTitle: String! private var originalTitle: String!
public convenience init(originalTitle: String) { convenience init(originalTitle: String) {
self.init(windowNibName: NSNib.Name(rawValue: "RenameSheet")) self.init(windowNibName: NSNib.Name(rawValue: "RenameSheet"))
self.originalTitle = originalTitle self.originalTitle = originalTitle
} }
override func windowDidLoad() {
newTitleTextField.stringValue = originalTitle
updateUI()
}
}
extension RenameWindowController: NSTextFieldDelegate {
override func controlTextDidChange(_ obj: Notification) {
updateUI()
}
}
private extension RenameWindowController {
func updateUI() {
let newTitle = newTitleTextField.stringValue
renameButton.isEnabled = !newTitle.isEmpty && newTitle != originalTitle
}
} }