[Info] Spelling checking in FireMonkey macOS

Demos, code samples. Only questions related to the existing topics are allowed here.
Post Reply
Sergey Tkachenko
Site Admin
Posts: 17602
Joined: Sat Aug 27, 2005 10:28 am
Contact:

[Info] Spelling checking in FireMonkey macOS

Post by Sergey Tkachenko »

In FireMonkey for macOS, the platform offers a spelling checking service, so text components (including TMemo and TRichViewEdit v20.5.1+) can use it.
Unfortunately, the default implementation of this service has several problems that make it almost unusable.
See https://quality.embarcadero.com/browse/RSP-39832

There is a workaround that solves the most important problem. It turns on language auto-detection instead of using two preferred dictionaries.
Add this code to your main form's unit.

Code: Select all

uses
  ...
  FMX.Platform,
  {$IFDEF MACOS}FMX.SpellChecker.Mac,{$ENDIF}
  ...;

{$IFDEF MACOS}
procedure SetMacSpellCheckerLanguageDetection;
var
  Svc: TMacSpellCheckerService;
begin
  TPlatformServices.Current.RemovePlatformService(IFMXSpellCheckerService);
  Svc := TMacSpellCheckerService.Create;
  Svc.MaxUsedPrefferedLanguagesCount := 0; // language auto-detection
  TPlatformServices.Current.AddPlatformService(IFMXSpellCheckerService, Svc);
end;
{$ENDIF}

initialization

  {$IFDEF MACOS}
  SetMacSpellCheckerLanguageDetection;
  {$ENDIF}
Post Reply