@@ -17,8 +17,10 @@ private let SwiftButtonProc: SUBCLASSPROC = { (hWnd, uMsg, wParam, lParam, uIdSu
17
17
}
18
18
19
19
20
+ /// A control that executes your custom code in response to user interactions.
20
21
public class Button : Control {
21
22
private static let `class` : WindowClass = WindowClass ( named: WC_BUTTON)
23
+
22
24
// MSDN:
23
25
// A button sends the `BN_DISABLE`, `BN_PUSHED`, `BN_KILLFOCUS`, `BN_PAINT`,
24
26
// `BN_SETFOCUS`, and `BN_UNPUSHED` notification codes only if it has the
@@ -27,15 +29,22 @@ public class Button: Control {
27
29
( base: WS_TABSTOP | DWORD ( BS_MULTILINE | BS_NOTIFY | BS_PUSHBUTTON) ,
28
30
extended: 0 )
29
31
32
+ // MARK - Creating Buttons
33
+
34
+ /// Creates a new button with the specified frame.
30
35
public init ( frame: Rect ) {
31
36
super. init ( frame: frame, class: Button . class, style: Button . style)
32
37
33
38
_ = SetWindowSubclass ( hWnd, SwiftButtonProc, UINT_PTR ( 1 ) ,
34
39
unsafeBitCast ( self as AnyObject , to: DWORD_PTR . self) )
35
40
}
36
41
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 " )
39
48
SetWindowTextW ( hWnd, title? . wide)
40
49
}
41
50
}
0 commit comments