zoukankan      html  css  js  c++  java
  • [修正] Firemonkey Windows & macOS 平台下 Edit & Memo 中文输入后会取消原选取文字的 BUG

    问题:Firemonkey Windows & macOS 平台下 Edit & Memo 中文输入后会取消原选取文字的 BUG

    适用版本:Delphi 10.1.2 & 10.2.1

    修正后效果:

     

    修正代码:

    请将 FMX.Edit.Style.pas 复制到自己的工程目录下,再修改如下代码: (10.2.2 已修正此问题)

    procedure TStyledEdit.IMEStateUpdated;
    var
      CombinedText: string;
    begin
      CombinedText := FTextService.CombinedText;
      FTextLayout.Text := CombinedText;
      SetCaretPosition(GetOriginCaretPosition);
      Model.SetTextWithoutValidation(CombinedText);
      if FPrompt <> nil then
        FPrompt.Visible := CombinedText.IsEmpty;
    {+++>}{$IF Defined(IOS) or Defined(ANDROID)} // 加入此行, 修正中文输入后会取消原选取文字的 BUG by Aone (2017.11.17)
      if Model.SelLength > 0 then
      begin
        Model.DisableNotify;
        try
          Model.SelLength := 0;
        finally
          Model.EnableNotify;
        end;
        UpdateSelectionPointPositions;
      end;
    {+++>}{$ENDIF} // 加入此行, 修正中文输入后会取消原选取文字的 BUG by Aone (2017.11.17)
      LinkObserversValueModified(Self.Observers);
      DoChangeTracking;
      DoTyping;
    end;

    请将 FMX.Memo.Style.pas 复制到自己的工程目录下,再修改如下代码:(10.2.2 未已修正此问题)

    procedure TStyledMemo.IMEStateUpdated;
    
    ...略...
    
        SelectionChanged := FSelected or (FSelStart <> LCaret) or (FSelEnd <> LCaret);
        CaretPosition := LCaret;
    {+++>}{$IF Defined(IOS) or Defined(ANDROID)} // 加入此行, 修正中文输入后会取消原选取文字的 BUG by Aone (2017.11.17)
        FSelStart := LCaret;
        FSelected := False;
        FSelEnd := FSelStart;
        UpdateSelectionInModel;
    {+++>}{$ENDIF} // 加入此行, 修正中文输入后会取消原选取文字的 BUG by Aone (2017.11.17)
    
        if SelectionChanged then
          UpdateSelectionPointPositions;
        if TextChanged then
          LinkObserversValueModified(Self.Observers);
      end;
    end;
  • 相关阅读:
    vim does not map customized key?
    再说vundle: 完全vim字符编程的四个必须插件
    centos7 没有iptables服务 file or directory? 用secureCRT登录centos?
    php基础语法-函数等
    windows下vmware10.0 安装centos7
    fedora23的firefox不能播放优酷视频?
    linux如何隐藏和显示所有窗口?
    fedora23忘记root密码怎么办??
    mouse scrollings and zooming operations in linux & windows are opposite
    windows 杂项
  • 原文地址:https://www.cnblogs.com/onechen/p/7852813.html
Copyright © 2011-2022 走看看