Disable macOS Smart Quotes feature in whole MAUI app or in BlazorWebView component for macCatalyst/iOS

Mat3o-9514 0 Reputation points
2023-01-14T01:54:52.8+00:00

Is there any way to disable globally Smart Quotes replacing mechanism in MAUI application for iOS/macOS? If not globally, is there maybe any option to disable this behavior per Page/Delegate or something? I tried to search any information, but there is a completely lack of xamarin/maui/dotnet sources on this topic.

I know there is option to disable this in system settings, but I came across Swift code snippets, where similar was achieved by setting related property of text field to something like "SmartQuotesType.No" (maybe it can help to discover right direction: in maui sources I found enum UIKit.UITextSmartQuotesType).

Developer technologies | .NET | .NET MAUI
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Wenyan Zhang (Shanghai Wicresoft Co,.Ltd.) 36,436 Reputation points Microsoft External Staff
    2023-01-16T05:25:14.73+00:00

    Hello,

    SmartQuotesType.No can be set for UIKit.UITextView.SmartQuotesType Property, UIKit.UISearchBar.SmartQuotesType Property, UIKit.UITextField.SmartQuotesType Property and UIKit.UITextDocumentProxy.SmartQuotesType Property, you could try to use handler to find the native control then set this property, refer to the following code: (There is no handler for UITextDocumentProxy in MAUI. If you use UITextDocumentProxy, you can set SmartQuotesType.No for it)

    #if MACCATALYST
           Microsoft.Maui.Handlers.EntryHandler.Mapper.AppendToMapping("custom", (handler,view) =>        {            
    handler.PlatformView.SmartDashesType = UIKit.UITextSmartDashesType.No;       
     });       
     Microsoft.Maui.Handlers.EditorHandler.Mapper.AppendToMapping("custom", (handler, view) =>        {            
    handler.PlatformView.SmartDashesType = UIKit.UITextSmartDashesType.No;        
    });        
    Microsoft.Maui.Handlers.SearchBarHandler.Mapper.AppendToMapping("custom", (handler, view) =>        {            
    handler.PlatformView.SmartDashesType = UIKit.UITextSmartDashesType.No;        
    });
    #endif
    

    Best Regards,

    Wenyan Zhang


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentationto enable e-mail notifications if you want to receive the related email notification for this thread.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.