iOS中的Delphi TEdit-在每个TEdit的基础上关闭自动大写 [英] Delphi TEdit in iOS - turn off auto-caps on a per TEdit basis

查看:37
本文介绍了iOS中的Delphi TEdit-在每个TEdit的基础上关闭自动大写的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当前,iOS TEdit在打开键盘时会将键盘的首字母大写.

Currently, the iOS TEdit when it brings up the Keyboard, will have the keyboard in Caps for first letter.

我想关闭键盘自动输入"功能,以关闭特定TEdit的首字母大写.一些TEdits我想保留首字母大写,例如Names.

I would like to turn off Keyboard auto going into Caps for first letter for specific TEdit. Some TEdits I would want to retain first letter as capitalized, eg Names.

我不能使用TEdit.CharCase功能,因为它会强制将TEdit中的所有输入都转换为小写.

I can't use the TEdit.CharCase feature as it forces all input in TEdit to lowercase.

我想要的是,如果用户愿意,可以键入大小写混合的字母,但是当TEdit首次成为焦点时,键盘必须使用小写字母.

What I want is that user can Type in Mixed Case if they choose to but the Keyboard has to be in lowercase when TEdit first comes into focus.

我如何在Delphi 10.4.1中做到这一点?

How do I do this in Delphi 10.4.1?

推荐答案

解决此问题的一种可能方法是:

One possible way to solve this is to:

使用公开显示的布尔引用(或添加到现有单元)创建一个单元,例如:

Create a unit with a Boolean reference (or add to an existing unit) that is exposed publicly, e.g:

unit iOSPatch;

interface

var
  DisableAutoCapitalization: Boolean;

implementation

end.

创建source \ fmx \ FMX.Platform.iOS.pas的副本并将其放在项目编译路径(例如项目文件夹)中

Create a copy of source\fmx\FMX.Platform.iOS.pas and put it in the project compile path (such as the project folder)

通过将第一步中的单元名称添加到实现use子句中来修改FMX.Platform.iOS的副本,例如:

Modify the copy of FMX.Platform.iOS by adding the unit name from the first step to the implementation uses clause, e.g.:

implementation
  
uses
  iOSPatch,
  System.Classes, System.SysUtils, System.Types, System.UITypes, System.TypInfo, System.Messaging, System.RTLConsts,
  // ... rest of uses clause snipped

修改TFMXViewBase.autocapitalizationType方法,使其看起来像这样:

Modify the TFMXViewBase.autocapitalizationType method to look like this:

function TFMXViewBase.autocapitalizationType: UITextAutocapitalizationType;
begin
  if DisableAutoCapitalization or FPassword or not (FKeyboardType in [TVirtualKeyboardType.Default, TVirtualKeyboardType.Alphabet, TVirtualKeyboardType.NamePhonePad]) then
    Result := UITextAutocapitalizationTypeNone
  else
    Result := UITextAutocapitalizationTypeSentences;
end;

使用每次编辑的OnEnter事件,根据需要将DisableAutoCapitalization设置为True/False.

Use the OnEnter event of every edit to set DisableAutoCapitalization to True/False depending on your needs

或者,如果您希望它无论如何都应用于所有编辑,则可以修改TFMXViewBase.autocapitalizationType以将Result设置为UITextAutocapitalizationTypeNone并忽略第一步.

Alternatively, if you want it to apply to all edits regardless, you could modify TFMXViewBase.autocapitalizationType to set Result to UITextAutocapitalizationTypeNone and ignore the first step.

不幸的是,由于在我的计算机上进行部署已经有些麻烦了,我现在无法对此进行测试

Unfortunately I can't test this right now as something has gone haywire with deployment on my machine

编辑

我设法解决了部署问题,并测试了上面的代码,该代码可以正常工作.轻微的副作用:VK上的Shift按钮显示为已按下",简短

I've managed to solve my deployment issue, and tested the code above, which works. Slight side-effect: the Shift button on the VK appears as "pressed" briefly

这篇关于iOS中的Delphi TEdit-在每个TEdit的基础上关闭自动大写的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆