| | |
| | | var isFocused: FocusState<Bool>.Binding |
| | | let onCommit: () -> Void |
| | | let onCancel: () -> Void |
| | | private static let placeholderAttributes: [NSAttributedString.Key: Any] = [ |
| | | .foregroundColor: NSColor.white.withAlphaComponent(0.48) |
| | | ] |
| | | |
| | | func makeCoordinator() -> Coordinator { |
| | | Coordinator( |
| | |
| | | field.focusRingType = .none |
| | | field.font = NSFont.systemFont(ofSize: 15, weight: .medium) |
| | | field.textColor = .white |
| | | field.placeholderString = placeholder |
| | | field.placeholderAttributedString = NSAttributedString( |
| | | string: placeholder, |
| | | attributes: Self.placeholderAttributes |
| | | ) |
| | | field.delegate = context.coordinator |
| | | field.target = context.coordinator |
| | | field.action = #selector(Coordinator.submitAction(_:)) |
| | |
| | | context.coordinator.onCommit = onCommit |
| | | context.coordinator.onCancel = onCancel |
| | | context.coordinator.field = field |
| | | field.placeholderString = placeholder |
| | | field.placeholderAttributedString = NSAttributedString( |
| | | string: placeholder, |
| | | attributes: Self.placeholderAttributes |
| | | ) |
| | | field.setAccessibilityLabel(placeholder) |
| | | |
| | | if !field.hasMarkedTextInput, field.stringValue != text { |