Recent

Author Topic: Tmemo add char like typing  (Read 902 times)

eldonfsr

  • Hero Member
  • *****
  • Posts: 528
Tmemo add char like typing
« 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?

 

CM630

  • Hero Member
  • *****
  • Posts: 1220
  • Не съм сигурен, че те разбирам.
    • http://sourceforge.net/u/cm630/profile/
Re: Tmemo add char like typing
« Reply #1 on: December 05, 2024, 09:22:22 pm »
I read your post multiple times, but I could not understand your question.
Лазар 4,0RC2 32 bit (sometimes 64 bit); FPC3,2,2

ackarwow

  • Full Member
  • ***
  • Posts: 127
    • Andrzej Karwowski's Homepage
Re: Tmemo add char like typing
« Reply #2 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.
« Last Edit: December 05, 2024, 10:55:10 pm by ackarwow »

eldonfsr

  • Hero Member
  • *****
  • Posts: 528
Re: Tmemo add char like typing
« Reply #3 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..

Remy Lebeau

  • Hero Member
  • *****
  • Posts: 1454
    • Lebeau Software
Re: Tmemo add char like typing
« Reply #4 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.
Remy Lebeau
Lebeau Software - Owner, Developer
Internet Direct (Indy) - Admin, Developer (Support forum)

ackarwow

  • Full Member
  • ***
  • Posts: 127
    • Andrzej Karwowski's Homepage
Re: Tmemo add char like typing
« Reply #5 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.

jcmontherock

  • Sr. Member
  • ****
  • Posts: 274
Re: Tmemo add char like typing
« Reply #6 on: December 07, 2024, 04:13:17 pm »
"Memo1.Append" maybe ?
Windows 11 UTF8-64 - Lazarus 4RC1-64 - FPC 3.2.2

Thaddy

  • Hero Member
  • *****
  • Posts: 16399
  • Censorship about opinions does not belong here.
Re: Tmemo add char like typing
« Reply #7 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.
« Last Edit: December 07, 2024, 04:49:26 pm by Thaddy »
There is nothing wrong with being blunt. At a minimum it is also honest.

 

TinyPortal © 2005-2018