[Libreoffice-commits] core.git: 2 commits - ios/experimental sal/inc vcl/ios
Tor Lillqvist
tml at iki.fi
Sat Apr 13 15:53:45 PDT 2013
ios/experimental/LibreOffice/LibreOffice/AppDelegate.h | 5 +-
ios/experimental/LibreOffice/LibreOffice/AppDelegate.m | 34 +++++++++++++----
ios/experimental/LibreOffice/LibreOffice/View.h | 7 ++-
ios/experimental/LibreOffice/LibreOffice/View.m | 24 ------------
sal/inc/osl/detail/ios-bootstrap.h | 1
vcl/ios/iosinst.cxx | 11 +++++
6 files changed, 47 insertions(+), 35 deletions(-)
New commits:
commit e3e040f671097e1675be80e2db294ad208e0b13c
Author: Tor Lillqvist <tml at iki.fi>
Date: Sun Apr 14 01:41:28 2013 +0300
Add text input to the iOS app
Don't have our View class implement the UIKeyInput protocol any
more. It won't work properly anyway. The docs say: "Only a small
subset of the available keyboards and languages are available to
classes that adopt this protocol".
Instead, use a transparent UITextView on top of our View to accept
keyboard input.
Seems to work as expected.
Change-Id: I3093ea7fbfa0ecab0dc5d0a38e5695723e8ed4ad
diff --git a/ios/experimental/LibreOffice/LibreOffice/AppDelegate.h b/ios/experimental/LibreOffice/LibreOffice/AppDelegate.h
index c5c4560..ebc7f69 100644
--- a/ios/experimental/LibreOffice/LibreOffice/AppDelegate.h
+++ b/ios/experimental/LibreOffice/LibreOffice/AppDelegate.h
@@ -10,12 +10,13 @@
#import "View.h"
- at interface AppDelegate : UIResponder <UIApplicationDelegate>
+ at interface AppDelegate : UIResponder <UIApplicationDelegate, UITextViewDelegate>
@property (strong, nonatomic) UIWindow *window;
@property (strong, nonatomic) View *view;
-- (void) threadMainMethod: (id) argument;
+- (void)threadMainMethod: (id) argument;
+- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text;
@end
diff --git a/ios/experimental/LibreOffice/LibreOffice/AppDelegate.m b/ios/experimental/LibreOffice/LibreOffice/AppDelegate.m
index 223ccf5..a12585b 100644
--- a/ios/experimental/LibreOffice/LibreOffice/AppDelegate.m
+++ b/ios/experimental/LibreOffice/LibreOffice/AppDelegate.m
@@ -16,7 +16,7 @@
#import "lo.h"
-static UIView *theView;
+static View *theView;
@implementation AppDelegate
@@ -41,6 +41,12 @@ static UIView *theView;
vc.view = self.view;
theView = self.view;
+ self.view->textView = [[UITextView alloc] initWithFrame: r];
+ self.view->textView.autocapitalizationType = UITextAutocapitalizationTypeNone;
+ self.view->textView.alpha = 0;
+ [self.view addSubview: self.view->textView];
+ self.view->textView.delegate = self;
+
UITapGestureRecognizer *tapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self.view action:@selector(tapGesture:)];
[self.window addGestureRecognizer: tapRecognizer];
@@ -68,6 +74,17 @@ static UIView *theView;
}
}
+- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text
+{
+ NSLog(@"textView: %@ shouldChangeTextInRange:[%u,%u] replacementText:%@", textView, range.location, range.length, text);
+ assert(textView == theView->textView);
+
+ for (NSUInteger i = 0; i < [text length]; i++)
+ lo_keyboard_input([text characterAtIndex: i]);
+
+ return NO;
+}
+
- (void)applicationWillResignActive:(UIApplication *)application
{
(void) application;
@@ -101,16 +118,17 @@ static UIView *theView;
[[info objectForKey:UIKeyboardFrameBeginUserInfoKey] getValue:&frameBegin];
[[info objectForKey:UIKeyboardFrameEndUserInfoKey] getValue:&frameEnd];
+
+ NSLog(@"keyboardWillShow: frame:%dx%d@(%d,%d)",
+ (int) frameEnd.size.width, (int) frameEnd.size.height,
+ (int) frameEnd.origin.x, (int) frameEnd.origin.y);
}
- (void)keyboardDidHide:(NSNotification *)note
{
- NSDictionary *info = [note userInfo];
- CGRect frameBegin;
- CGRect frameEnd;
+ (void) note;
- [[info objectForKey:UIKeyboardFrameBeginUserInfoKey] getValue:&frameBegin];
- [[info objectForKey:UIKeyboardFrameEndUserInfoKey] getValue:&frameEnd];
+ NSLog(@"keyboardDidHide");
lo_keyboard_did_hide();
}
@@ -129,14 +147,14 @@ void lo_damaged(CGRect rect)
void lo_show_keyboard()
{
dispatch_async(dispatch_get_main_queue(), ^{
- [theView becomeFirstResponder];
+ [theView->textView becomeFirstResponder];
});
}
void lo_hide_keyboard()
{
dispatch_async(dispatch_get_main_queue(), ^{
- [theView resignFirstResponder];
+ [theView->textView resignFirstResponder];
});
}
diff --git a/ios/experimental/LibreOffice/LibreOffice/View.h b/ios/experimental/LibreOffice/LibreOffice/View.h
index a50b8f3..b0e8394 100644
--- a/ios/experimental/LibreOffice/LibreOffice/View.h
+++ b/ios/experimental/LibreOffice/LibreOffice/View.h
@@ -9,8 +9,11 @@
#import <UIKit/UIKit.h>
- at interface View : UIView <UIKeyInput>
-
+ at interface View : UIView
+{
+ at public
+ UITextView* textView;
+}
- (void)drawRect:(CGRect)rect;
- (void)tapGesture:(UIGestureRecognizer *)gestureRecognizer;
diff --git a/ios/experimental/LibreOffice/LibreOffice/View.m b/ios/experimental/LibreOffice/LibreOffice/View.m
index 43edc2f..2dd4ab8 100644
--- a/ios/experimental/LibreOffice/LibreOffice/View.m
+++ b/ios/experimental/LibreOffice/LibreOffice/View.m
@@ -34,33 +34,11 @@
CGPoint location = [gestureRecognizer locationInView: self];
NSLog(@"tapGesture: at: (%d,%d)", (int)location.x, (int)location.y);
lo_tap(location.x, location.y);
+ [self->textView becomeFirstResponder];
} else
NSLog(@"tapGesture: %@", gestureRecognizer);
}
-- (void)insertText:(NSString *)text
-{
- (void) text;
- // Do something with the typed character
-}
-
-- (void)deleteBackward
-{
- // Handle the delete key
-}
-
-- (BOOL)hasText
-{
- // Return whether there's any text present
- return YES;
-}
-
-- (BOOL)canBecomeFirstResponder
-{
- return YES;
-}
-
-
@end
// vim:set shiftwidth=4 softtabstop=4 expandtab:
commit 6b89688829fa2758419361b1ac0598b72a3e3423
Author: Tor Lillqvist <tml at iki.fi>
Date: Sun Apr 14 01:40:46 2013 +0300
Add lo_keyboard_input()
Change-Id: I5904f673de9854af47eefac2f192295a281c5525
diff --git a/sal/inc/osl/detail/ios-bootstrap.h b/sal/inc/osl/detail/ios-bootstrap.h
index c96706a..4738eeb 100644
--- a/sal/inc/osl/detail/ios-bootstrap.h
+++ b/sal/inc/osl/detail/ios-bootstrap.h
@@ -49,6 +49,7 @@ void lo_runMain();
void lo_set_view_size(int width, int height);
void lo_render_windows(CGContextRef context, CGRect rect);
void lo_tap(int x, int y);
+void lo_keyboard_input(int c);
#ifdef __cplusplus
}
diff --git a/vcl/ios/iosinst.cxx b/vcl/ios/iosinst.cxx
index ebf44ac..920187c 100644
--- a/vcl/ios/iosinst.cxx
+++ b/vcl/ios/iosinst.cxx
@@ -370,6 +370,17 @@ void lo_tap(int x, int y)
}
extern "C"
+void lo_keyboard_input(int c)
+{
+ SalFrame *pFocus = IosSalInstance::getInstance()->getFocusFrame();
+ if (pFocus) {
+ KeyEvent aEvent(c, c, 0);
+ Application::PostKeyEvent(VCLEVENT_WINDOW_KEYINPUT, pFocus->GetWindow(), &aEvent);
+ Application::PostKeyEvent(VCLEVENT_WINDOW_KEYUP, pFocus->GetWindow(), &aEvent);
+ }
+}
+
+extern "C"
void lo_keyboard_did_hide()
{
// Tell LO it has lost "focus", which will cause it to stop
More information about the Libreoffice-commits
mailing list