@@ -20,6 +20,8 @@ extension CollectionType {
20
20
@objc public protocol KeyboardLayoutDelegate {
21
21
optional func keyboardLayoutDidStartPressingButton( keyboardLayout: KeyboardLayout , keyboardButton: KeyboardButton )
22
22
optional func keyboardLayoutDidPressButton( keyboardLayout: KeyboardLayout , keyboardButton: KeyboardButton )
23
+ optional func keyboardLayoutDidDraggedInButton( keyboardLayout: KeyboardLayout , keyboardButton: KeyboardButton )
24
+ optional func keyboardLayoutDidEndTouches( keyboardLayout: KeyboardLayout )
23
25
}
24
26
25
27
// MARK: - KeyboardLayoutStyle
@@ -149,9 +151,9 @@ public class KeyboardLayout: UIView {
149
151
super. touchesBegan ( touches, withEvent: event)
150
152
for touch in touches {
151
153
if let button = hitTest ( touch. locationInView ( self ) , withEvent: nil ) as? KeyboardButton {
154
+ delegate? . keyboardLayoutDidStartPressingButton ? ( self , keyboardButton: button)
152
155
for row in rows {
153
156
row. highlightButton ( button)
154
- delegate? . keyboardLayoutDidStartPressingButton ? ( self , keyboardButton: button)
155
157
}
156
158
}
157
159
}
@@ -161,6 +163,7 @@ public class KeyboardLayout: UIView {
161
163
super. touchesMoved ( touches, withEvent: event)
162
164
if let touch = touches. first {
163
165
if let button = hitTest ( touch. locationInView ( self ) , withEvent: nil ) as? KeyboardButton {
166
+ delegate? . keyboardLayoutDidDraggedInButton ? ( self , keyboardButton: button)
164
167
for row in rows {
165
168
row. highlightButton ( button)
166
169
}
@@ -170,6 +173,7 @@ public class KeyboardLayout: UIView {
170
173
171
174
public override func touchesEnded( touches: Set < UITouch > , withEvent event: UIEvent ? ) {
172
175
super. touchesEnded ( touches, withEvent: event)
176
+ delegate? . keyboardLayoutDidEndTouches ? ( self )
173
177
for row in rows {
174
178
row. unhighlightButtons ( )
175
179
}
@@ -182,6 +186,7 @@ public class KeyboardLayout: UIView {
182
186
183
187
public override func touchesCancelled( touches: Set < UITouch > ? , withEvent event: UIEvent ? ) {
184
188
super. touchesCancelled ( touches, withEvent: event)
189
+ delegate? . keyboardLayoutDidEndTouches ? ( self )
185
190
for row in rows {
186
191
row. unhighlightButtons ( )
187
192
}
0 commit comments