Skip to content

Commit 4bcff3a

Browse files
committed
FIx key popup add/remove on custom container
1 parent 27c7e89 commit 4bcff3a

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

Keyboard/DefaultKeyboard/CustomKeyboard.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,6 @@ public class CustomKeyboard: UIView, KeyboardLayoutDelegate {
219219
delegate?.customKeyboardButtonPressed?(self, keyboardButton: keyboardButton)
220220
invalidateBackspaceAutoDeleteModeTimer()
221221
invalidateBackspaceDeleteTimer()
222-
removeKeyPopup()
223222
if keyboardLayout == currentLayout {
224223
switch keyboardButton.type {
225224
case .Key(let key):
@@ -294,4 +293,8 @@ public class CustomKeyboard: UIView, KeyboardLayoutDelegate {
294293
removeKeyPopup()
295294
addKeyPopup(forKey: keyboardButton)
296295
}
296+
297+
public func keyboardLayoutDidEndTouches(keyboardLayout: KeyboardLayout) {
298+
removeKeyPopup()
299+
}
297300
}

Keyboard/KeyboardLayoutEngine/KeyboardLayout.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ extension CollectionType {
2020
@objc public protocol KeyboardLayoutDelegate {
2121
optional func keyboardLayoutDidStartPressingButton(keyboardLayout: KeyboardLayout, keyboardButton: KeyboardButton)
2222
optional func keyboardLayoutDidPressButton(keyboardLayout: KeyboardLayout, keyboardButton: KeyboardButton)
23+
optional func keyboardLayoutDidDraggedInButton(keyboardLayout: KeyboardLayout, keyboardButton: KeyboardButton)
24+
optional func keyboardLayoutDidEndTouches(keyboardLayout: KeyboardLayout)
2325
}
2426

2527
// MARK: - KeyboardLayoutStyle
@@ -149,9 +151,9 @@ public class KeyboardLayout: UIView {
149151
super.touchesBegan(touches, withEvent: event)
150152
for touch in touches {
151153
if let button = hitTest(touch.locationInView(self), withEvent: nil) as? KeyboardButton {
154+
delegate?.keyboardLayoutDidStartPressingButton?(self, keyboardButton: button)
152155
for row in rows {
153156
row.highlightButton(button)
154-
delegate?.keyboardLayoutDidStartPressingButton?(self, keyboardButton: button)
155157
}
156158
}
157159
}
@@ -161,6 +163,7 @@ public class KeyboardLayout: UIView {
161163
super.touchesMoved(touches, withEvent: event)
162164
if let touch = touches.first {
163165
if let button = hitTest(touch.locationInView(self), withEvent: nil) as? KeyboardButton {
166+
delegate?.keyboardLayoutDidDraggedInButton?(self, keyboardButton: button)
164167
for row in rows {
165168
row.highlightButton(button)
166169
}
@@ -170,6 +173,7 @@ public class KeyboardLayout: UIView {
170173

171174
public override func touchesEnded(touches: Set<UITouch>, withEvent event: UIEvent?) {
172175
super.touchesEnded(touches, withEvent: event)
176+
delegate?.keyboardLayoutDidEndTouches?(self)
173177
for row in rows {
174178
row.unhighlightButtons()
175179
}
@@ -182,6 +186,7 @@ public class KeyboardLayout: UIView {
182186

183187
public override func touchesCancelled(touches: Set<UITouch>?, withEvent event: UIEvent?) {
184188
super.touchesCancelled(touches, withEvent: event)
189+
delegate?.keyboardLayoutDidEndTouches?(self)
185190
for row in rows {
186191
row.unhighlightButtons()
187192
}

0 commit comments

Comments
 (0)