Skip to content

Commit

Permalink
placeholder
Browse files Browse the repository at this point in the history
  • Loading branch information
RomanPodymov committed Oct 30, 2023
1 parent c7a4b85 commit 468af20
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
20 changes: 19 additions & 1 deletion Sources/CommonAppleKit/CommonAppleKit.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,13 @@

public extension CATextField {
var stringValue: String {
text ?? ""
get {
text ?? ""
}

set {
text = newValue
}
}
}

Expand Down Expand Up @@ -87,6 +93,18 @@
public typealias CAWindow = NSWindow
public typealias CARect = NSRect

public extension CATextField {
var placeholder: String {
set {
placeholderString = newValue
}

get {
placeholderString ?? ""
}
}
}

public extension CAImage {
@available(macOS 11.0, *)
convenience init?(systemName: String) {
Expand Down
8 changes: 8 additions & 0 deletions Tests/CommonAppleKitTests/CommonAppleKitTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@ private final class ViewA: CAView {
}

final class CommonAppleKitTests: XCTestCase {
func testTextField() {
let textField = CATextField()
textField.stringValue = "Hello"
textField.placeholder = "world"
XCTAssertEqual(textField.stringValue, "Hello")
XCTAssertEqual(textField.placeholder, "world")
}

func testButton() {
let button = CAButton()
let selector = #selector(Self.onButtonTap)
Expand Down

0 comments on commit 468af20

Please sign in to comment.