Skip to content

Commit

Permalink
fix: checkboxes preferences were unchecked initially
Browse files Browse the repository at this point in the history
  • Loading branch information
lwouis committed Apr 2, 2020
1 parent 4915b57 commit b091282
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/ui/preferences-window/LabelAndControl.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@ class LabelAndControl: NSObject {

static func makeLabelWithCheckbox(_ labelText: String, _ rawName: String, extraAction: ActionClosure? = nil, labelPosition: LabelPosition = .leftWithSeparator) -> [NSView] {
let checkbox = NSButton(checkboxWithTitle: labelPosition == .right ? labelText : "", target: nil, action: nil)
let views = makeLabelWithProvidedControl(labelText, rawName, checkbox, labelPosition: labelPosition, extraAction: extraAction)
setControlValue(checkbox, Preferences.getString(rawName)!)
checkbox.sendAction(checkbox.action, to: checkbox.target)
let views = makeLabelWithProvidedControl(labelText, rawName, checkbox, labelPosition: labelPosition, extraAction: extraAction)
return views
}

Expand Down Expand Up @@ -117,7 +116,7 @@ class LabelAndControl: NSObject {
control.stringValue = value
(control as! NSTextField).delegate?.controlTextDidChange?(Notification(name: NSControl.textDidChangeNotification, object: control))
} else if control is NSButton {
(control as! NSButton).state = Bool(value) ?? false ? NSButton.StateValue.on : NSButton.StateValue.off
(control as! NSButton).state = (value as NSString).boolValue ? .on : .off
} else {
control.stringValue = value
}
Expand Down

0 comments on commit b091282

Please sign in to comment.