fix view lift not working on first keyboard invoke.
This commit is contained in:
1 parent
746479d359
commit
e5fa7f9c72
3 files changed
+17
-20
No files matched your search
@@ -15,7 +15,7 @@
|
||||
|
||||
@property (nonatomic, assign) uint8_t numberOfTouchesRequired;
|
||||
@property (nonatomic, assign) double tapDownTimeThreshold;
|
||||
@property (nonatomic, readonly) CGFloat lowestTouchPointHeight;
|
||||
@property (atomic, readonly) CGFloat lowestTouchPointHeight;
|
||||
|
||||
|
||||
@end
|
||||
|
||||
@@ -32,14 +32,12 @@ static CGFloat lowestTouchPointYCoord = 0.0;
|
||||
for(UITouch *touch in [event allTouches]){
|
||||
if(lowestTouchPointYCoord < [touch locationInView:self.view].y) lowestTouchPointYCoord = [touch locationInView:self.view].y;
|
||||
}
|
||||
//NSLog(@"lowestTouchPointYCoord: %f ", lowestTouchPointYCoord);
|
||||
_lowestTouchPointHeight = screenHeightInPoints - lowestTouchPointYCoord;
|
||||
self.state = UIGestureRecognizerStatePossible;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)touchesEnded:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
|
||||
|
||||
// [super touchesEnded:touches withEvent:event];
|
||||
if(multiFingerDown && [[event allTouches] count] == [touches count]){
|
||||
multiFingerDown = false;
|
||||
@@ -50,4 +48,10 @@ static CGFloat lowestTouchPointYCoord = 0.0;
|
||||
}
|
||||
}
|
||||
|
||||
+ (CGFloat)lowestTouchPointHeight{
|
||||
@synchronized (self){
|
||||
return self.lowestTouchPointHeight;
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -51,7 +51,7 @@ static const double X1_MOUSE_SPEED_DIVISOR = 2.5;
|
||||
|
||||
NSDictionary<NSString *, NSNumber *> *dictCodes;
|
||||
CustomTapGestureRecognizer *keyboardToggleRecognizer;
|
||||
CGFloat liftViewToHeight;
|
||||
CGFloat HeightViewLiftedTo;
|
||||
}
|
||||
|
||||
- (void) setupStreamView:(ControllerSupport*)controllerSupport
|
||||
@@ -156,34 +156,32 @@ static const double X1_MOUSE_SPEED_DIVISOR = 2.5;
|
||||
[self becomeFirstResponder];
|
||||
}
|
||||
|
||||
|
||||
- (void)keyboardWillShow:(NSNotification *)notification{
|
||||
if(settings.liftStreamViewForKeyboard && !isInputingText){
|
||||
NSDictionary *userInfo = notification.userInfo;
|
||||
// Get the keyboard size from the notification
|
||||
CGRect keyboardFrame = [userInfo[UIKeyboardFrameEndUserInfoKey] CGRectValue];
|
||||
liftViewToHeight = keyboardFrame.size.height - keyboardToggleRecognizer.lowestTouchPointHeight + CGRectGetHeight([[UIScreen mainScreen] bounds]) * 0.1; // lift the StreamView to the height of lowest touch point of multi-finger tap gesture, while reserving the view of 1/10 screen height for remote typing.
|
||||
if(liftViewToHeight < 0) liftViewToHeight = 0; // set liftViewtoHeight to 0 if it is high enough and not going to be covered by keyboard.
|
||||
// NSLog(@"keyboard height %f, lowest point height %f", keyboardFrame.size.height, keyboardToggleRecognizer.lowestTouchPointHeight);
|
||||
if(keyboardFrame.size.height < CGRectGetHeight([[UIScreen mainScreen] bounds]) * 0.25) return; // return in case of abnormal keyboard height
|
||||
HeightViewLiftedTo = keyboardFrame.size.height - keyboardToggleRecognizer.lowestTouchPointHeight + CGRectGetHeight([[UIScreen mainScreen] bounds]) * 0.1; // lift the StreamView to the height of lowest touch point of multi-finger tap gesture, while reserving the view of 1/10 screen height for remote typing.
|
||||
if(HeightViewLiftedTo < 0) HeightViewLiftedTo = 0; // set HeightViewLiftedTo to 0 if it is high enough and not going to be covered by keyboard.
|
||||
CGRect liftedStreamFrame = self.frame;
|
||||
liftedStreamFrame.origin.y -= liftViewToHeight;
|
||||
liftedStreamFrame.origin.y -= HeightViewLiftedTo;
|
||||
self.frame = liftedStreamFrame;
|
||||
}
|
||||
|
||||
|
||||
isInputingText = true;
|
||||
}
|
||||
// NSLog(@"keyboard will show");
|
||||
}
|
||||
|
||||
- (void)keyboardWillHide:(NSNotification *)notification{
|
||||
|
||||
if(settings.liftStreamViewForKeyboard && isInputingText){
|
||||
if(isInputingText){
|
||||
CGRect liftedStreamFrame = self.frame;
|
||||
// recover view position in keyboard hiding.
|
||||
liftedStreamFrame.origin.y += liftViewToHeight;
|
||||
liftedStreamFrame.origin.y += HeightViewLiftedTo;
|
||||
self.frame = liftedStreamFrame;
|
||||
}
|
||||
|
||||
isInputingText = false;
|
||||
}
|
||||
// NSLog(@"keyboard will hide");
|
||||
}
|
||||
|
||||
@@ -191,12 +189,8 @@ static const double X1_MOUSE_SPEED_DIVISOR = 2.5;
|
||||
- (void)toggleKeyboard{
|
||||
if (isInputingText) {
|
||||
Log(LOG_D, @"Closing the keyboard");
|
||||
// NSLog(@"Closing the keyboard");
|
||||
[keyInputField resignFirstResponder];
|
||||
isInputingText = false;
|
||||
} else {
|
||||
|
||||
// NSLog(@"Opening the keyboard");
|
||||
Log(LOG_D, @"Opening the keyboard");
|
||||
// Prepare the textbox used to capture keyboard events.
|
||||
keyInputField.delegate = self;
|
||||
@@ -223,7 +217,6 @@ static const double X1_MOUSE_SPEED_DIVISOR = 2.5;
|
||||
[keyInputField addTarget:self action:@selector(onKeyboardPressed:) forControlEvents:UIControlEventEditingChanged];
|
||||
// Undo causes issues for our state management, so turn it off
|
||||
[keyInputField.undoManager disableUndoRegistration];
|
||||
//isInputingText = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user