Lazarus

Programming => Packages and Libraries => Topic started by: eldonfsr on December 05, 2024, 06:09:53 pm

Title: Tmemo add char like typing
Post by: eldonfsr on December 05, 2024, 06:09:53 pm
is there a way to add char or string like typing  on  tmemo

i need trigger onkeypress like typing but mem.text := mem,text+'A'  or mem.lines[2] := mem.lines[2]+'A'

can be possible?

 
Title: Re: Tmemo add char like typing
Post by: CM630 on December 05, 2024, 09:22:22 pm
I read your post multiple times, but I could not understand your question.
Title: Re: Tmemo add char like typing
Post by: ackarwow on December 05, 2024, 10:47:59 pm
is there a way to add char or string like typing  on  tmemo

i need trigger onkeypress like typing but mem.text := mem,text+'A'  or mem.lines[2] := mem.lines[2]+'A'

can be possible?

Hi eldonfsr
There are no OnKeyPress events in this case but for example OnChange event is triggered.
Title: Re: Tmemo add char like typing
Post by: eldonfsr on December 06, 2024, 03:06:11 pm
well is onchange is is trigger when i typing but let play with it enable and disable event..
Title: Re: Tmemo add char like typing
Post by: Remy Lebeau on December 06, 2024, 06:32:47 pm
is there a way to add char or string like typing  on  tmemo

It is not efficient to retrieve the entire Text, append to it, and then replace the entire Text.  Try this simpler approach instead:

Code: [Select]
Mem.SelStart := Mem.GetTextLen;
Mem.SelLength := 0;
Mem.SelText := 'A';

That will append the new text to the end of the Memo's internal data.
Title: Re: Tmemo add char like typing
Post by: ackarwow on December 06, 2024, 08:41:20 pm
well is onchange is is trigger when i typing but let play with it enable and disable event..
if you don't need the OnChange event, you can just ignore it.
Title: Re: Tmemo add char like typing
Post by: jcmontherock on December 07, 2024, 04:13:17 pm
"Memo1.Append" maybe ?
Title: Re: Tmemo add char like typing
Post by: Thaddy on December 07, 2024, 04:41:44 pm
I think he wants to mimic real typing, so with a random delay between the characters?
I am not even bothered to write an example, because it is too easy.
If an answer is not there I will do it tomorrow. Hint: use randomrange(120,350) per char.
TinyPortal © 2005-2018