如何在Delphi 10中选择TEdit字段文本

时间:2017-12-21 01:33:46

标签: delphi firemonkey

我有一个非常基本的问题,我无法弄清楚原因。我想在字段获得焦点时选择TEdit的文本。在带有VCL的Delphi 7中,您可以在OnEnter事件中执行此操作:

TEdit(Sender).SelLength := Length(TEdit(Sender).Text)

现在,使用Delphi 10.2和FireMonkey,我已经尝试过几种不同的方式,但它不起作用。

示例:

procedure TfPrincipal.Edit1Enter(Sender: TObject);
begin
   TEdit(Sender).SetFocus;
   TEdit(Sender).SelStart  := 0; // I already tried to change this value
   TEdit(Sender).SelLength := Length(TEdit(Sender).Text); // I already tried to change this value too
end;

1 个答案:

答案 0 :(得分:0)

您是否尝试过匿名线程中的SelectAll

D:\encdec\Encoders-decoders\DuckToolkit-master>python ducktools.py -e -l us test.txt ducky.bin
[+] Reading Input file.
  [-] Encoding File
Traceback (most recent call last):
  File "ducktools.py", line 58, in <module>
    duck_bin = encoder.encode_script(duck_text, language)
  File "D:\encdec\Encoders-decoders\DuckToolkit-master\ducktoolkit\encoder.py", line 160, in encode_script
    encoded_file = parse_text(duck_text, lang_file, bunny).decode()
  File "D:\encdec\Encoders-decoders\DuckToolkit-master\ducktoolkit\encoder.py", line 24, in parse_text
    duck_text = duck_text.replace("\r", "")
TypeError: expected bytes, bytearray or buffer compatible object