Skip to content

Commit 6a05316

Browse files
committed
Button: add some documentation comments
Add some documentation comments and an assertion for Button.
1 parent 0df05a6 commit 6a05316

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

Sources/SwiftWin32/Views and Controls/Button.swift

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@ private let SwiftButtonProc: SUBCLASSPROC = { (hWnd, uMsg, wParam, lParam, uIdSu
1717
}
1818

1919

20+
/// A control that executes your custom code in response to user interactions.
2021
public class Button: Control {
2122
private static let `class`: WindowClass = WindowClass(named: WC_BUTTON)
23+
2224
// MSDN:
2325
// A button sends the `BN_DISABLE`, `BN_PUSHED`, `BN_KILLFOCUS`, `BN_PAINT`,
2426
// `BN_SETFOCUS`, and `BN_UNPUSHED` notification codes only if it has the
@@ -27,15 +29,22 @@ public class Button: Control {
2729
(base: WS_TABSTOP | DWORD(BS_MULTILINE | BS_NOTIFY | BS_PUSHBUTTON),
2830
extended: 0)
2931

32+
// MARK - Creating Buttons
33+
34+
/// Creates a new button with the specified frame.
3035
public init(frame: Rect) {
3136
super.init(frame: frame, class: Button.class, style: Button.style)
3237

3338
_ = SetWindowSubclass(hWnd, SwiftButtonProc, UINT_PTR(1),
3439
unsafeBitCast(self as AnyObject, to: DWORD_PTR.self))
3540
}
3641

37-
// FIXME(compnerd) handle title setting for different states
38-
public func setTitle(_ title: String?, forState _: Control.State) {
42+
// MARK - Configuring the Button Title
43+
44+
/// Sets the title to use for the specified state.
45+
public func setTitle(_ title: String?, forState state: Control.State) {
46+
// FIXME(compnerd) handle title setting for different states
47+
assert(state == .normal, "state handling not yet implemented")
3948
SetWindowTextW(hWnd, title?.wide)
4049
}
4150
}

0 commit comments

Comments
 (0)