Skip to content
This repository has been archived by the owner on Oct 30, 2018. It is now read-only.

Commit

Permalink
Uses UIKeyCommand as parameter instead of generic object
Browse files Browse the repository at this point in the history
  • Loading branch information
Ignacio Romero Zurbuchen committed Feb 13, 2016
1 parent 5c27485 commit 5901e68
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 15 deletions.
6 changes: 2 additions & 4 deletions Examples/Messenger-Shared/MessageViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -422,15 +422,13 @@ - (void)didPressRightButton:(id)sender
[super didPressRightButton:sender];
}

- (void)didPressArrowKey:(id)sender
- (void)didPressArrowKey:(UIKeyCommand *)keyCommand
{
UIKeyCommand *keyCommand = (UIKeyCommand *)sender;

if ([keyCommand.input isEqualToString:UIKeyInputUpArrow] && self.textView.text.length == 0) {
[self editLastMessage:nil];
}
else {
[super didPressArrowKey:sender];
[super didPressArrowKey:keyCommand];
}
}

Expand Down
2 changes: 1 addition & 1 deletion Source/SLKTextView.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ typedef NS_OPTIONS(NSUInteger, SLKPastableMediaType) {
/**
Notifies the text view that the user pressed any arrow key. This is used to move the cursor up and down while having multiple lines.
*/
- (void)didPressAnyArrowKey:(UIKeyCommand *)keyCommand;
- (void)didPressArrowKey:(UIKeyCommand *)keyCommand;


#pragma mark - Markdown Formatting
Expand Down
2 changes: 1 addition & 1 deletion Source/SLKTextView.m
Original file line number Diff line number Diff line change
Expand Up @@ -975,7 +975,7 @@ - (NSArray *)keyCommands

#pragma mark Up/Down Cursor Movement

- (void)didPressAnyArrowKey:(UIKeyCommand *)keyCommand
- (void)didPressArrowKey:(UIKeyCommand *)keyCommand
{
if (![keyCommand isKindOfClass:[UIKeyCommand class]] || self.text.length == 0 || self.numberOfLines < 2) {
return;
Expand Down
6 changes: 3 additions & 3 deletions Source/SLKTextViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -321,21 +321,21 @@ NS_CLASS_AVAILABLE_IOS(7_0) @interface SLKTextViewController : UIViewController
You can override this method to perform additional tasks.
You MUST call super at some point in your implementation.
*/
- (void)didPressReturnKey:(id)sender NS_REQUIRES_SUPER;
- (void)didPressReturnKey:(UIKeyCommand *)keyCommand NS_REQUIRES_SUPER;

/**
Notifies the view controller when the user has pressed the Escape key (Esc) with an external keyboard.
You can override this method to perform additional tasks.
You MUST call super at some point in your implementation.
*/
- (void)didPressEscapeKey:(id)sender NS_REQUIRES_SUPER;
- (void)didPressEscapeKey:(UIKeyCommand *)keyCommand NS_REQUIRES_SUPER;

/**
Notifies the view controller when the user has pressed the arrow key with an external keyboard.
You can override this method to perform additional tasks.
You MUST call super at some point in your implementation.
*/
- (void)didPressArrowKey:(id)sender NS_REQUIRES_SUPER;
- (void)didPressArrowKey:(UIKeyCommand *)keyCommand NS_REQUIRES_SUPER;


#pragma mark - Text Input Bar Adjustment
Expand Down
12 changes: 6 additions & 6 deletions Source/SLKTextViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -1283,23 +1283,23 @@ - (void)slk_prepareForInterfaceTransitionWithDuration:(NSTimeInterval)duration

#pragma mark - Keyboard Events

- (void)didPressReturnKey:(id)sender
- (void)didPressReturnKey:(UIKeyCommand *)keyCommand
{
if (_textInputbar.isEditing) {
[self didCommitTextEditing:sender];
[self didCommitTextEditing:keyCommand];
}
else {
[self slk_performRightAction];
}
}

- (void)didPressEscapeKey:(id)sender
- (void)didPressEscapeKey:(UIKeyCommand *)keyCommand
{
if (self.isAutoCompleting) {
[self cancelAutoCompletion];
}
else if (_textInputbar.isEditing) {
[self didCancelTextEditing:sender];
[self didCancelTextEditing:keyCommand];
}

if ([self ignoreTextInputbarAdjustment] || ([self.textView isFirstResponder] && self.keyboardHC.constant == 0)) {
Expand All @@ -1309,9 +1309,9 @@ - (void)didPressEscapeKey:(id)sender
[self dismissKeyboard:YES];
}

- (void)didPressArrowKey:(id)sender
- (void)didPressArrowKey:(UIKeyCommand *)keyCommand
{
[self.textView didPressAnyArrowKey:sender];
[self.textView didPressArrowKey:keyCommand];
}


Expand Down

0 comments on commit 5901e68

Please sign in to comment.