summaryrefslogtreecommitdiff
path: root/src/ios.m
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2021-12-09 15:06:02 +0200
committerJaakko Keränen <jaakko.keranen@iki.fi>2021-12-09 15:06:02 +0200
commita265ab290cc9bce2f0c305a3eaf9d743380b967b (patch)
treeb0842b3fa63ecfb7b135341e40abf70659bf1101 /src/ios.m
parent38bc51a65be35488857249e5ed5949172f06ee89 (diff)
iOS: Fixes and new edit menu for UploadWidget
The sizing and behavior of the input field on the plain text upload page is much improved.
Diffstat (limited to 'src/ios.m')
-rw-r--r--src/ios.m37
1 files changed, 34 insertions, 3 deletions
diff --git a/src/ios.m b/src/ios.m
index 2705a350..b6fbdec0 100644
--- a/src/ios.m
+++ b/src/ios.m
@@ -536,6 +536,15 @@ void pickFile_iOS(const char *command) {
536 [viewController_(get_Window()) presentViewController:picker animated:YES completion:nil]; 536 [viewController_(get_Window()) presentViewController:picker animated:YES completion:nil];
537} 537}
538 538
539void openTextActivityView_iOS(const iString *text) {
540 UIActivityViewController *actView =
541 [[UIActivityViewController alloc]
542 initWithActivityItems:@[
543 [NSString stringWithUTF8String:cstr_String(text)]]
544 applicationActivities:nil];
545 [viewController_(get_Window()) presentViewController:actView animated:YES completion:nil];
546}
547
539/*----------------------------------------------------------------------------------------------*/ 548/*----------------------------------------------------------------------------------------------*/
540 549
541enum iAVFAudioPlayerState { 550enum iAVFAudioPlayerState {
@@ -784,7 +793,16 @@ void deinit_SystemTextInput(iSystemTextInput *d) {
784 } 793 }
785} 794}
786 795
787void setText_SystemTextInput(iSystemTextInput *d, const iString *text) { 796void selectAll_SystemTextInput(iSystemTextInput *d) {
797 if (d->field) {
798 [REF_d_field selectAll:nil];
799 }
800 if (d->view) {
801 [REF_d_view selectAll:nil];
802 }
803}
804
805void setText_SystemTextInput(iSystemTextInput *d, const iString *text, iBool allowUndo) {
788 NSString *str = [NSString stringWithUTF8String:cstr_String(text)]; 806 NSString *str = [NSString stringWithUTF8String:cstr_String(text)];
789 if (d->field) { 807 if (d->field) {
790 [REF_d_field setText:str]; 808 [REF_d_field setText:str];
@@ -793,9 +811,22 @@ void setText_SystemTextInput(iSystemTextInput *d, const iString *text) {
793 } 811 }
794 } 812 }
795 else { 813 else {
796 [REF_d_view setText:str]; 814 UITextView *view = REF_d_view;
815// if (allowUndo) {
816// [view selectAll:nil];
817// if ([view shouldChangeTextInRange:[view selectedTextRange] replacementText:@""]) {
818// [[view textStorage] beginEditing];
819// [[view textStorage] replaceCharactersInRange:[view selectedRange] withString:@""];
820// [[view textStorage] endEditing];
821// }
822// }
823// else {
824 // TODO: How to implement `allowUndo`, given that UITextView does not exist when unfocused?
825 // Maybe keep the UITextStorage (if it has the undo?)?
826 [view setText:str];
827// }
797 if (d->flags & selectAll_SystemTextInputFlags) { 828 if (d->flags & selectAll_SystemTextInputFlags) {
798 [REF_d_view selectAll:nil]; 829 [view selectAll:nil];
799 } 830 }
800 } 831 }
801} 832}