Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't select all text on UITextView using mac catalyst APIs #15156

Closed
pictos opened this issue May 31, 2022 · 1 comment
Closed

Can't select all text on UITextView using mac catalyst APIs #15156

pictos opened this issue May 31, 2022 · 1 comment
Labels
support The issue is related to support

Comments

@pictos
Copy link

pictos commented May 31, 2022

Hello there, first of all, don't know if it's a bug or if I'm missing something. But I can't select the text inside the MauiEditor control (UITextView in the Apple world).

if you want/need a more complex sample you can check the CommunityToolkit.MAUI sample in this PR

Steps to Reproduce

  1. Run the attached repo
  2. click on the last Editor control
  3. See that the text isn't selected
  4. Click on the second Entry and see that the text will select all text

Expected Behavior

The second Editor control select all text

Actual Behavior

The second Editor doesn't select all text

Example Project (If Possible)

uitextview_bug_repro.zip

Environment

Version information ``` Visual Studio Enterprise 2022 for Mac Preview Version 17.3 Preview (17.3 build 198) Installation UUID: c444bfb6-7971-4bd2-8b2a-981dccbe4c17

Runtime
.NET 6.0.3 (64-bit)
Architecture: Arm64

Roslyn (Language Service)
4.2.0-3.22181.8+a59a22c6f3c2cc1883e20cece412209f18f4a29f

NuGet
Version: 6.0.0.262

.NET SDK (Arm64)
SDK: /usr/local/share/dotnet/sdk/6.0.300/Sdks
SDK Versions:
6.0.300
6.0.203
6.0.202
6.0.201
MSBuild SDKs: /usr/local/share/dotnet/sdk/6.0.300/Sdks

.NET SDK (x64)
SDK Versions:
3.1.419
3.1.418
3.1.417

.NET Runtime (Arm64)
Runtime: /usr/local/share/dotnet/dotnet
Runtime Versions:
6.0.5
6.0.4
6.0.3

.NET Runtime (x64)
Runtime: /usr/local/share/dotnet/x64/dotnet
Runtime Versions:
3.1.25
3.1.24
3.1.23

Xamarin.Profiler
Version: 1.8.0.19
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler

Updater
Version: 11

Apple Developer Tools
Xcode 13.4 (20503)
Build 13F17a

Xamarin.Mac
Xamarin.Mac not installed. Can't find /Library/Frameworks/Xamarin.Mac.framework/Versions/Current/Version.

Xamarin.iOS
Version: 15.10.0.1 (Visual Studio Enterprise)
Hash: 568bdb2
Branch: d17-2
Build date: 2022-04-08 18:52:57-0400

Xamarin Designer
Version: 17.3.0.70
Hash: 4cf1a2208
Branch: remotes/origin/d17-3
Build date: 2022-05-25 15:22:03 UTC

Xamarin.Android
Version: 12.3.99.58 (Visual Studio Enterprise)
Commit: xamarin-android/main/64b22fc
Android SDK: /Users/pedrojesus/Library/Developer/Xamarin/android-sdk-macosx
Supported Android versions:
12.0 (API level 31)
8.1 (API level 27)
11.0 (API level 30)
10.0 (API level 29)
9.0 (API level 28)

SDK Command-line Tools Version: 5.0
SDK Platform Tools Version: 31.0.3
SDK Build Tools Version: 30.0.3

Build Information:
Mono: adf1bc4
Java.Interop: xamarin/java.interop/release/6.0.3xx@2a882d2d
ProGuard: Guardsquare/proguard@912d149
SQLite: xamarin/sqlite@7b1e016
Xamarin.Android Tools: xamarin/xamarin-android-tools/main@fc3c2ac

Microsoft Build of OpenJDK
Java SDK: /Library/Java/JavaVirtualMachines/microsoft-11.jdk
11.0.12
Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL

Eclipse Temurin JDK
Java SDK: /Library/Java/JavaVirtualMachines/temurin-8.jdk
1.8.0.302
Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL

Android SDK Manager
Version: 17.2.0.47
Hash: d6dd135
Branch: remotes/origin/dev/tondat/main-1512059~2
Build date: 2022-05-25 15:21:57 UTC

Android Device Manager
Version: 0.0.0.1127
Hash: 4bb4d48
Branch: remotes/origin/dev/tondat/main-1536295~1
Build date: 2022-05-25 15:21:57 UTC

Build Information
Release ID: 1703000198
Git revision: b61a5879556b3b4d5270ffffd9431e5ec7db233d
Build date: 2022-05-25 15:20:15+00
Build branch: release-17.3
Build lane: release-17.3

Operating System
Mac OS X 12.4.0
Darwin 21.5.0 Darwin Kernel Version 21.5.0
Tue Apr 26 21:08:37 PDT 2022
root:xnu-8020.121.3~4/RELEASE_ARM64_T6000 arm64

</details>

### Build Logs



@rolfbjarne
Copy link
Member

This looks like just how Mac Catalyst handles events.

First you get called for textViewDidBeginEditing, where you call selectAll:

(lldb) bt
* thread #1, name = 'tid_103', queue = 'com.apple.main-thread', stop reason = breakpoint 1.23
  * frame #0: 0x00007ff9220eb37f UIKitCore`-[UITextInputController setSelectedTextRange:]
    frame #1: 0x00007ff922110639 UIKitCore`-[UITextView setSelectedTextRange:] + 148
    frame #2: 0x00007ff92209f1c7 UIKitCore`-[UITextSelection commit] + 293
    frame #3: 0x00007ff922092990 UIKitCore`-[UITextInteractionAssistant(UITextInteractionAssistant_Internal) selectAll:] + 218
    frame #4: 0x00007ff922115700 UIKitCore`-[UITextView selectAll:] + 79
    frame #5: 0x00000001009901cc libxamarin-dotnet-debug.dylib`xamarin_dyn_objc_msgSendSuper + 220
    frame #6: 0x00000001000167f7 uitextview_bug_repro`interp_to_native_trampoline + 167
    frame #7: 0x00000001011d34a2 libmonosgen-2.0.dylib`ves_pinvoke_method + 482
    frame #8: 0x00000001011c54b4 libmonosgen-2.0.dylib`interp_exec_method + 3284
    frame #9: 0x00000001011c35ff libmonosgen-2.0.dylib`interp_runtime_invoke + 239
    frame #10: 0x00000001010ba856 libmonosgen-2.0.dylib`mono_jit_runtime_invoke + 1238
    frame #11: 0x0000000100fd77af libmonosgen-2.0.dylib`mono_runtime_try_invoke + 143
    frame #12: 0x0000000100fd9b3f libmonosgen-2.0.dylib`mono_runtime_invoke + 95
    frame #13: 0x0000000100039e25 uitextview_bug_repro`native_to_managed_trampoline_11(self=0x000060000060eb20, _cmd="textViewDidBeginEditing:", managed_method_ptr=0x00000001001f39e8, p0=0x0000000103a37000, token_ref=16227) at Microsoft.MacCatalyst.registrar.maccatalyst-x64.m:645:2
    frame #14: 0x00000001000a7972 uitextview_bug_repro`-[UIKit_UITextView__UITextViewDelegate textViewDidBeginEditing:](self=0x000060000060eb20, _cmd="textViewDidBeginEditing:", p0=0x0000000103a37000) at Microsoft.MacCatalyst.registrar.maccatalyst-x64.m:45632:3
    frame #15: 0x00007ff92210c796 UIKitCore`-[UITextView _notifyDidBeginEditing] + 69
    frame #16: 0x00007ff92210c2dc UIKitCore`-[UITextView becomeFirstResponder] + 669
    frame #17: 0x00007ff9220914c8 UIKitCore`-[UITextInteractionAssistant(UITextInteractionAssistant_Internal) setFirstResponderIfNecessaryActivatingSelection:] + 194
    frame #18: 0x00007ff92206e4f8 UIKitCore`-[UITextSelectionInteraction _checkForRepeatedTap:gestureLocationOut:] + 272
    frame #19: 0x00007ff92206f077 UIKitCore`-[UITextSelectionInteraction _handleMultiTapGesture:] + 700
    frame #20: 0x00007ff9213cb2a0 UIKitCore`-[UIApplication sendAction:to:from:forEvent:] + 83
    frame #21: 0x00007ff9219a0342 UIKitCore`-[UITextMultiTapRecognizer onStateUpdate:] + 169
    frame #22: 0x00007ff92139866b UIKitCore`-[UIGestureRecognizerTarget _sendActionWithGestureRecognizer:] + 44
    frame #23: 0x00007ff9213984ee UIKitCore`_UIGestureRecognizerSendTargetActions + 109
    frame #24: 0x00007ff921398198 UIKitCore`_UIGestureRecognizerSendActions + 328
    frame #25: 0x00007ff921a4192c UIKitCore`-[UIGestureRecognizer _updateGestureForActiveEvents] + 638
    frame #26: 0x00007ff92110efa0 UIKitCore`_UIGestureEnvironmentUpdate + 2799
    frame #27: 0x00007ff9213921f7 UIKitCore`-[UIGestureEnvironment _deliverEvent:toGestureRecognizers:usingBlock:] + 448
    frame #28: 0x00007ff921391b50 UIKitCore`-[UIGestureEnvironment _updateForEvent:window:] + 254
    frame #29: 0x00007ff9213917f6 UIKitCore`-[UIWindow sendEvent:] + 5287
(lldb) po $rdx
<_UITextKitTextRange: 0x600000672fa0> (0, 642)

then Mac Catalyst handles the actual click, and puts the cursor (and deselects all basically) where you clicked:

(lldb) bt
* thread #1, name = 'tid_103', queue = 'com.apple.main-thread', stop reason = breakpoint 1.30
  * frame #0: 0x00007ff9221105a5 UIKitCore`-[UITextView setSelectedTextRange:]
    frame #1: 0x00007ff92209f1c7 UIKitCore`-[UITextSelection commit] + 293
    frame #2: 0x00007ff921d108a4 UIKitCore`-[_UIKeyboardTextSelectionController selectPositionAtPoint:granularity:completionHandler:] + 404
    frame #3: 0x00007ff92206eb0c UIKitCore`-[UITextSelectionInteraction tappedToPositionCursorWithGesture:atPoint:granularity:completionHandler:] + 283
    frame #4: 0x00007ff92206e8c4 UIKitCore`-[UITextSelectionInteraction _checkForRepeatedTap:gestureLocationOut:] + 1244
    frame #5: 0x00007ff92206f077 UIKitCore`-[UITextSelectionInteraction _handleMultiTapGesture:] + 700
    frame #6: 0x00007ff9213cb2a0 UIKitCore`-[UIApplication sendAction:to:from:forEvent:] + 83
    frame #7: 0x00007ff9219a0342 UIKitCore`-[UITextMultiTapRecognizer onStateUpdate:] + 169
    frame #8: 0x00007ff92139866b UIKitCore`-[UIGestureRecognizerTarget _sendActionWithGestureRecognizer:] + 44
    frame #9: 0x00007ff9213984ee UIKitCore`_UIGestureRecognizerSendTargetActions + 109
    frame #10: 0x00007ff921398198 UIKitCore`_UIGestureRecognizerSendActions + 328
    frame #11: 0x00007ff921a4192c UIKitCore`-[UIGestureRecognizer _updateGestureForActiveEvents] + 638
    frame #12: 0x00007ff92110efa0 UIKitCore`_UIGestureEnvironmentUpdate + 2799
    frame #13: 0x00007ff9213921f7 UIKitCore`-[UIGestureEnvironment _deliverEvent:toGestureRecognizers:usingBlock:] + 448
    frame #14: 0x00007ff921391b50 UIKitCore`-[UIGestureEnvironment _updateForEvent:window:] + 254
    frame #15: 0x00007ff9213917f6 UIKitCore`-[UIWindow sendEvent:] + 5287
(lldb) po $rdx
<_UITextKitTextRange: 0x600000667560> (219, 0)

Another point is that if you tab into the text view, or right click it, then the entire text is selected.

This doesn't look like a bug in xamarin-macios, so I'm closing this. If you feel this is wrong, please feel free to reopen and we'll have a look again.

@rolfbjarne rolfbjarne added the support The issue is related to support label May 31, 2022
@ghost ghost locked as resolved and limited conversation to collaborators Jun 30, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
support The issue is related to support
Projects
None yet
Development

No branches or pull requests

2 participants