@@ -8,56 +8,120 @@ open class Responder {
88
99 /// Returns the next responder in the responder chain, or `nil` if there is no
1010 /// next responder.
11- public var next : Responder ? { nil }
11+ open var next : Responder ? { nil }
1212
1313 /// Indicates whether this object is the first responder.
14- public var isFirstResponder : Bool { return self . next === self }
14+ open var isFirstResponder : Bool { return self . next === self }
1515
1616 /// Indiciates whether ths object can become the first responder.
17- public var canBecomeFirstResponder : Bool { false }
18-
19- /// Indicates whether this object is willing to relinquish first-responder
20- /// status.
21- public var canResignFirstResponder : Bool { true }
17+ open var canBecomeFirstResponder : Bool { false }
2218
2319 /// Results to make this object the first responder in its window.
24- public func becomeFirstResponder( ) -> Bool {
20+ open func becomeFirstResponder( ) -> Bool {
2521 guard !self . isFirstResponder else { return true }
2622 guard self . canBecomeFirstResponder else { return false }
2723 return true
2824 }
2925
26+ /// Indicates whether this object is willing to relinquish first-responder
27+ /// status.
28+ open var canResignFirstResponder : Bool { true }
29+
3030 /// Notifies the object that it has been asked to relinquish its status as
3131 /// first responder in its window.
32- public func resignFirstResponder( ) -> Bool {
32+ open func resignFirstResponder( ) -> Bool {
3333 return true
3434 }
3535
3636 // MARK - Responding to Touch Events
3737
3838 /// Informs the responder that one or more new touches occurrd in a view or a
3939 /// window.
40- public func touchesBegan( _ touches: Set < Touch > , with event: Event ? ) {
40+ open func touchesBegan( _ touches: Set < Touch > , with event: Event ? ) {
4141 }
4242
4343 /// Informs the responder when one or more touches associated with an event
4444 /// changed.
45- public func touchesMoved( _ touches: Set < Touch > , with event: Event ? ) {
45+ open func touchesMoved( _ touches: Set < Touch > , with event: Event ? ) {
4646 }
4747
4848 /// Informs the responder when one or more fingers are raised from a view or a
4949 /// window.
50- public func touchesEnded( _ touches: Set < Touch > , with event: Event ? ) {
50+ open func touchesEnded( _ touches: Set < Touch > , with event: Event ? ) {
5151 }
5252
5353 /// Informs the responder when a system event (such as a system alert) cancels
5454 /// a touch sequence.
55- public func touchesCancelled( _ touches: Set < Touch > , with event: Event ? ) {
55+ open func touchesCancelled( _ touches: Set < Touch > , with event: Event ? ) {
5656 }
5757
5858 /// Tells the responder that updated values were received for previously
5959 /// estimated properties or that an update is no longer expected.
60- public func touchesEstimatedPropertiesUpdated( _ touches: Set < Touch > ) {
60+ open func touchesEstimatedPropertiesUpdated( _ touches: Set < Touch > ) {
61+ }
62+
63+ // MARK - Responding to Motion Events
64+
65+ /// Tells the receiver that a motion event has begun.
66+ open func motionBegan( _ motion: Event . EventSubtype , with event: Event ? ) {
67+ }
68+
69+ /// Tells the receiver that a motion event has ended.
70+ open func motionEnded( _ motion: Event . EventSubtype , with event: Event ? ) {
71+ }
72+
73+ /// Tells the receiver that a motion event has been cancelled.
74+ open func motionCancelled( _ motion: Event . EventSubtype , with event: Event ? ) {
75+ }
76+
77+ // MARK - Responding to Press Events
78+
79+ /// NOTE: Generally, responders that handle press events should override all
80+ /// four of these methods.
81+
82+ /// Tells this object when a physical button is first pressed.
83+ open func pressesBegan( _ presses: Set < Press > , with event: PressesEvent ? ) {
84+ }
85+
86+ /// Tells this object when a value associated with a press has changed.
87+ open func pressesChanged( _ presses: Set < Press > , with event: PressesEvent ? ) {
88+ }
89+
90+ /// Tells the object when a button is released.
91+ open func pressesEnded( _ presses: Set < Press > , with event: PressesEvent ? ) {
92+ }
93+
94+ /// Tells this object when a system event (such as a low-memory warning) cancels a press event.
95+ open func pressesCancelled( _ presses: Set < Press > , with event: PressesEvent ? ) {
96+ }
97+
98+ // MARK - Responding to Remote-Control Events
99+
100+ /// Tells the object when a remote-control event is received.
101+ open func remoteControlReceived( with event: Event ? ) {
102+ }
103+
104+ // MARK - Managing Input Views
105+
106+ /// The custom input view to display when the receiver becomes the first
107+ /// responder.
108+ open private( set) var inputView : View ?
109+
110+ /// The custom input view controller to use when the receiver becomes the
111+ /// first responder.
112+ open private( set) var inputViewController : InputViewController ?
113+
114+ /// The custom input accessory view to display when the receiver becomes the
115+ /// first responder.
116+ open private( set) var inputAccessoryView : View ?
117+
118+ /// The custom input accessory view controller to display when the receiver
119+ /// becomes the first responder.
120+ open private( set) var inputAccessoryViewController : InputViewController ?
121+
122+ /// Updates the custom input and accessory views when the object is the first
123+ /// responder.
124+ open func reloadInputViews( ) {
61125 }
62126
63127 // MARK - Building and Validating Commands
@@ -68,11 +132,24 @@ open class Responder {
68132 }
69133
70134 /// Asks the receiving responder to validate the command.
71- open func validate( _ command: Command ) {
135+ public func validate( _ command: Command ) {
72136 self . next? . validate ( command)
73137 }
74138
75- // MARK - Constants
139+ /// Requests the receiving responder to enable or disable the specified
140+ /// command in the user interface.
141+ open func canPerformAction( _ action: ( AnyObject ) -> ( _: Action , _: Any ? ) -> Void ,
142+ withSender sender: Any ? ) -> Bool {
143+ fatalError ( " \( #function) not yet implemented " )
144+ }
145+
146+ open func target( forAction action: ( AnyObject ) -> ( _: Action , _: Any ? ) -> Void ,
147+ withSender sender: Any ? ) -> Any ? {
148+ guard canPerformAction ( action, withSender: sender) else { return nil }
149+ fatalError ( " \( #function) not yet implemented " )
150+ }
151+
152+ // MARK - Responding to Keyboard Notifications
76153
77154 /// A user info key to retrieve the animation curve that the system uses to
78155 /// animate the keyboard onto or off the screen.
0 commit comments