Implement view lifting for keyboard invoke.
This commit is contained in:
1 parent
6b48083ad9
commit
d54205dec8
5 files changed
+39
-7
No files matched your search
@@ -15,6 +15,8 @@
|
|||||||
|
|
||||||
@property (nonatomic, assign) uint8_t numberOfTouchesRequired;
|
@property (nonatomic, assign) uint8_t numberOfTouchesRequired;
|
||||||
@property (nonatomic, assign) double tapDownTimeThreshold;
|
@property (nonatomic, assign) double tapDownTimeThreshold;
|
||||||
|
@property (nonatomic, readonly) CGFloat lowestTouchPointHeight;
|
||||||
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
#endif /* CustomTapGestureRecognizer_h */
|
#endif /* CustomTapGestureRecognizer_h */
|
||||||
@@ -14,9 +14,12 @@
|
|||||||
|
|
||||||
static NSTimeInterval multiFingerDownTime;
|
static NSTimeInterval multiFingerDownTime;
|
||||||
static bool multiFingerDown;
|
static bool multiFingerDown;
|
||||||
|
static CGFloat screenHeightInPoints;
|
||||||
|
static CGFloat lowestTouchPointYCoord = 0.0;
|
||||||
|
|
||||||
- (instancetype)initWithTarget:(nullable id)target action:(nullable SEL)action {
|
- (instancetype)initWithTarget:(nullable id)target action:(nullable SEL)action {
|
||||||
self = [super initWithTarget:target action:action];
|
self = [super initWithTarget:target action:action];
|
||||||
|
screenHeightInPoints = CGRectGetHeight([[UIScreen mainScreen] bounds]);
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -25,15 +28,25 @@ static bool multiFingerDown;
|
|||||||
if ([[event allTouches] count] == _numberOfTouchesRequired) {
|
if ([[event allTouches] count] == _numberOfTouchesRequired) {
|
||||||
multiFingerDownTime = CACurrentMediaTime();
|
multiFingerDownTime = CACurrentMediaTime();
|
||||||
multiFingerDown = true;
|
multiFingerDown = true;
|
||||||
|
|
||||||
|
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;
|
self.state = UIGestureRecognizerStatePossible;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)touchesEnded:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
|
- (void)touchesEnded:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
|
||||||
|
|
||||||
// [super touchesEnded:touches withEvent:event];
|
// [super touchesEnded:touches withEvent:event];
|
||||||
if(multiFingerDown && [[event allTouches] count] == [touches count]){
|
if(multiFingerDown && [[event allTouches] count] == [touches count]){
|
||||||
multiFingerDown = false;
|
multiFingerDown = false;
|
||||||
if((CACurrentMediaTime() - multiFingerDownTime) < _tapDownTimeThreshold / 1000) self.state = UIGestureRecognizerStateRecognized;
|
if((CACurrentMediaTime() - multiFingerDownTime) < _tapDownTimeThreshold / 1000){
|
||||||
|
lowestTouchPointYCoord = 0.0; //reset for next recognition
|
||||||
|
self.state = UIGestureRecognizerStateRecognized;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ static const double X1_MOUSE_SPEED_DIVISOR = 2.5;
|
|||||||
|
|
||||||
NSDictionary<NSString *, NSNumber *> *dictCodes;
|
NSDictionary<NSString *, NSNumber *> *dictCodes;
|
||||||
CustomTapGestureRecognizer *keyboardToggleRecognizer;
|
CustomTapGestureRecognizer *keyboardToggleRecognizer;
|
||||||
|
CGFloat liftViewToHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) setupStreamView:(ControllerSupport*)controllerSupport
|
- (void) setupStreamView:(ControllerSupport*)controllerSupport
|
||||||
@@ -76,12 +77,12 @@ static const double X1_MOUSE_SPEED_DIVISOR = 2.5;
|
|||||||
keyboardToggleRecognizer.delaysTouchesBegan = NO;
|
keyboardToggleRecognizer.delaysTouchesBegan = NO;
|
||||||
keyboardToggleRecognizer.delaysTouchesEnded = NO;
|
keyboardToggleRecognizer.delaysTouchesEnded = NO;
|
||||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||||
selector:@selector(keyboardWillShow)
|
selector:@selector(keyboardWillShow:)
|
||||||
name:UIKeyboardWillShowNotification
|
name:UIKeyboardWillShowNotification
|
||||||
object:nil];
|
object:nil];
|
||||||
|
|
||||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||||
selector:@selector(keyboardWillHide)
|
selector:@selector(keyboardWillHide:)
|
||||||
name:UIKeyboardWillHideNotification
|
name:UIKeyboardWillHideNotification
|
||||||
object:nil];
|
object:nil];
|
||||||
[self addGestureRecognizer:keyboardToggleRecognizer];
|
[self addGestureRecognizer:keyboardToggleRecognizer];
|
||||||
@@ -152,12 +153,27 @@ static const double X1_MOUSE_SPEED_DIVISOR = 2.5;
|
|||||||
[self becomeFirstResponder];
|
[self becomeFirstResponder];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)keyboardWillShow{
|
|
||||||
|
- (void)keyboardWillShow:(NSNotification *)notification{
|
||||||
|
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.
|
||||||
|
|
||||||
|
CGRect liftedStreamFrame = self.frame;
|
||||||
|
liftedStreamFrame.origin.y -= liftViewToHeight;
|
||||||
|
self.frame = liftedStreamFrame;
|
||||||
|
|
||||||
isInputingText = true;
|
isInputingText = true;
|
||||||
// NSLog(@"keyboard will show");
|
// NSLog(@"keyboard will show");
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)keyboardWillHide{
|
- (void)keyboardWillHide:(NSNotification *)notification{
|
||||||
|
CGRect liftedStreamFrame = self.frame;
|
||||||
|
// recover view position in keyboard hiding.
|
||||||
|
liftedStreamFrame.origin.y += liftViewToHeight;
|
||||||
|
self.frame = liftedStreamFrame;
|
||||||
isInputingText = false;
|
isInputingText = false;
|
||||||
// NSLog(@"keyboard will hide");
|
// NSLog(@"keyboard will hide");
|
||||||
}
|
}
|
||||||
@@ -170,6 +186,7 @@ static const double X1_MOUSE_SPEED_DIVISOR = 2.5;
|
|||||||
[keyInputField resignFirstResponder];
|
[keyInputField resignFirstResponder];
|
||||||
isInputingText = false;
|
isInputingText = false;
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
// NSLog(@"Opening the keyboard");
|
// NSLog(@"Opening the keyboard");
|
||||||
Log(LOG_D, @"Opening the keyboard");
|
Log(LOG_D, @"Opening the keyboard");
|
||||||
// Prepare the textbox used to capture keyboard events.
|
// Prepare the textbox used to capture keyboard events.
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
<key>CFBundleDevelopmentRegion</key>
|
<key>CFBundleDevelopmentRegion</key>
|
||||||
<string>en</string>
|
<string>en</string>
|
||||||
<key>CFBundleDisplayName</key>
|
<key>CFBundleDisplayName</key>
|
||||||
<string>Moonlight-ZWM</string>
|
<string>Moonlight-ZWM-Debug</string>
|
||||||
<key>CFBundleExecutable</key>
|
<key>CFBundleExecutable</key>
|
||||||
<string>${EXECUTABLE_NAME}</string>
|
<string>${EXECUTABLE_NAME}</string>
|
||||||
<key>CFBundleIdentifier</key>
|
<key>CFBundleIdentifier</key>
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
<key>CFBundleDevelopmentRegion</key>
|
<key>CFBundleDevelopmentRegion</key>
|
||||||
<string>$(DEVELOPMENT_LANGUAGE)</string>
|
<string>$(DEVELOPMENT_LANGUAGE)</string>
|
||||||
<key>CFBundleDisplayName</key>
|
<key>CFBundleDisplayName</key>
|
||||||
<string>Moonlight-ZWM</string>
|
<string>Moonlight-ZWM-Debug</string>
|
||||||
<key>CFBundleExecutable</key>
|
<key>CFBundleExecutable</key>
|
||||||
<string>$(EXECUTABLE_NAME)</string>
|
<string>$(EXECUTABLE_NAME)</string>
|
||||||
<key>CFBundleIdentifier</key>
|
<key>CFBundleIdentifier</key>
|
||||||
|
|||||||
Reference in new issue
Block a user