Disable inline editing in the sidebar. Fix #156.
This commit is contained in:
parent
379126b701
commit
b891341ea6
|
@ -1,7 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.Storyboard.XIB" version="3.0" toolsVersion="14460.31" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" initialViewController="B8D-0N-5wS">
|
||||
<dependencies>
|
||||
<deployment identifier="macosx"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14460.31"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
|
@ -319,14 +318,11 @@
|
|||
<textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="fst-vi-Wue" userLabel="Text field">
|
||||
<rect key="frame" x="25" y="0.0" width="120" height="17"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||
<textFieldCell key="cell" lineBreakMode="truncatingTail" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" title="Table View Cell" usesSingleLineMode="YES" id="axz-6y-tjw">
|
||||
<textFieldCell key="cell" lineBreakMode="truncatingTail" allowsUndo="NO" sendsActionOnEndEditing="YES" title="Table View Cell" usesSingleLineMode="YES" id="axz-6y-tjw">
|
||||
<font key="font" metaFont="system"/>
|
||||
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
|
||||
</textFieldCell>
|
||||
<connections>
|
||||
<action selector="editingEnded:" target="HJn-Tm-YNO" id="dGd-n1-zvp"/>
|
||||
</connections>
|
||||
</textField>
|
||||
</subviews>
|
||||
<connections>
|
||||
|
|
|
@ -16,12 +16,6 @@ private var textSizeCache = [String: NSSize]()
|
|||
|
||||
class SidebarCell : NSTableCellView {
|
||||
|
||||
override var objectValue: Any? {
|
||||
didSet {
|
||||
didSetObjectValue()
|
||||
}
|
||||
}
|
||||
|
||||
var image: NSImage? {
|
||||
didSet {
|
||||
if let image = image {
|
||||
|
@ -94,7 +88,6 @@ class SidebarCell : NSTableCellView {
|
|||
override var textField: NSTextField? {
|
||||
didSet {
|
||||
textField?.translatesAutoresizingMaskIntoConstraints = false
|
||||
updateTextFieldIsEditable()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -134,12 +127,6 @@ class SidebarCell : NSTableCellView {
|
|||
let layout = SidebarCellLayout(appearance: cellAppearance, cellSize: bounds.size, shouldShowImage: shouldShowImage, textField: textField, unreadCountView: unreadCountView)
|
||||
layoutWith(layout)
|
||||
}
|
||||
|
||||
@IBAction func editingEnded(_ sender: NSTextField) {
|
||||
if let renamableItem = node?.representedObject as? Renamable {
|
||||
renamableItem.rename(to: sender.stringValue)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private extension SidebarCell {
|
||||
|
@ -149,17 +136,5 @@ private extension SidebarCell {
|
|||
textField?.rs_setFrameIfNotEqual(layout.titleRect)
|
||||
unreadCountView.rs_setFrameIfNotEqual(layout.unreadCountRect)
|
||||
}
|
||||
|
||||
func didSetObjectValue() {
|
||||
updateTextFieldIsEditable()
|
||||
}
|
||||
|
||||
func updateTextFieldIsEditable() {
|
||||
var canRename = false
|
||||
if let _ = node?.representedObject as? Renamable {
|
||||
canRename = true
|
||||
}
|
||||
textField?.isEditable = canRename
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue