diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-12-09 15:06:02 +0200 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-12-09 15:06:02 +0200 |
commit | a265ab290cc9bce2f0c305a3eaf9d743380b967b (patch) | |
tree | b0842b3fa63ecfb7b135341e40abf70659bf1101 /src/ios.m | |
parent | 38bc51a65be35488857249e5ed5949172f06ee89 (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.m | 37 |
1 files changed, 34 insertions, 3 deletions
@@ -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 | ||
539 | void 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 | ||
541 | enum iAVFAudioPlayerState { | 550 | enum iAVFAudioPlayerState { |
@@ -784,7 +793,16 @@ void deinit_SystemTextInput(iSystemTextInput *d) { | |||
784 | } | 793 | } |
785 | } | 794 | } |
786 | 795 | ||
787 | void setText_SystemTextInput(iSystemTextInput *d, const iString *text) { | 796 | void 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 | |||
805 | void 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 | } |