Skip to content

Commit 64ed38a

Browse files
committed
Adding notifications for when the expanded input view is shown or hidden.
1 parent 78079cf commit 64ed38a

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

CYRKeyboardButton/CYRKeyboardButton.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,16 @@ typedef NS_ENUM(NSUInteger, CYRKeyboardButtonStyle) {
5555
*/
5656
extern NSString *const CYRKeyboardButtonPressedNotification;
5757

58+
/**
59+
Notifies observers that the keyboard button has show the expanded input view. The affected button is stored in the object parameter of the notification.
60+
*/
61+
extern NSString *const CYRKeyboardButtonDidShowExpandedInputNotification;
62+
63+
/**
64+
Notifies observers that the keyboard button has hidden the expanded input view. The affected button is stored in the object parameter of the notification.
65+
*/
66+
extern NSString *const CYRKeyboardButtonDidHideExpandedInputNotification;
67+
5868
/**
5969
The key used to fetch the pressed key string from the userInfo dictionary returned when CYRKeyboardButtonPressedNotification is fired.
6070
*/

CYRKeyboardButton/CYRKeyboardButton.m

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@
3535
#import "CYRKeyboardButtonView.h"
3636

3737
NSString *const CYRKeyboardButtonPressedNotification = @"CYRKeyboardButtonPressedNotification";
38+
NSString *const CYRKeyboardButtonDidShowExpandedInputNotification = @"CYRKeyboardButtonDidShowExpandedInputNotification";
39+
NSString *const CYRKeyboardButtonDidHideExpandedInputNotification = @"CYRKeyboardButtonDidHideExpandedInputNotification";
3840
NSString *const CYRKeyboardButtonKeyPressedKey = @"CYRKeyboardButtonKeyPressedKey";
3941

4042
@interface CYRKeyboardButton () <UIGestureRecognizerDelegate>
@@ -235,6 +237,8 @@ - (void)showExpandedInputView:(UILongPressGestureRecognizer *)recognizer
235237
[self.window addSubview:expandedButtonView];
236238
self.expandedButtonView = expandedButtonView;
237239

240+
[[NSNotificationCenter defaultCenter] postNotificationName:CYRKeyboardButtonDidShowExpandedInputNotification object:self];
241+
238242
[self hideInputView];
239243
}
240244
} else if (recognizer.state == UIGestureRecognizerStateCancelled || recognizer.state == UIGestureRecognizerStateEnded) {
@@ -254,6 +258,10 @@ - (void)hideInputView
254258

255259
- (void)hideExpandedInputView
256260
{
261+
if (self.expandedButtonView.type == CYRKeyboardButtonViewTypeExpanded) {
262+
[[NSNotificationCenter defaultCenter] postNotificationName:CYRKeyboardButtonDidHideExpandedInputNotification object:self];
263+
}
264+
257265
[self.expandedButtonView removeFromSuperview];
258266
self.expandedButtonView = nil;
259267
}

0 commit comments

Comments
 (0)