[Lazarus] Memo for touchscreen

Malcolm Poole malcolm at lingua-z.co.uk
Tue Aug 27 18:50:40 CEST 2013

On 26/08/13 20:33, Koenraad Lelong wrote:
>> procedure TForm1.LetterAButtonClick ( Sender: TObject ) ;
>> var
>> testcaretpos: Integer;
>> begin
>> testcaretpos := Memo1.SelStart;
>> Memo1.Text := Copy(Memo1.Text, 1, testcaretpos) + 'A'
>> + Copy(Memo1.Text, testcaretpos+1, MaxInt);
>> Inc(testcaretpos);
>> Memo1.SelStart := testcaretpos;
>> Memo1.SetFocus;
>> end;
> I made a few testprograms that work fine with your code. Now I made a
> full keyboard (Belgian AZERTY) and I'm having a problem I can't solve.
> The keyboard has some "special" characters : é§èçà and others. Those are
> not 1 byte characters. When I add them, they appear in the memo, but the
> next character seems to erase the memo. If I have already some lines in
> it, all disappears and the cursor is on the first line, fully left.
> I add the characters with a string :
> Kars:='§';
> Memo1.Text := Copy(Memo1.Text, 1, testcaretpos) + Kars +
> Copy(Memo1.Text, testcaretpos+1, MaxInt);

This happens because '§' and the other 'characters' are represented in 
UTF8 by more than one byte.

I reproduced your problem and got around it by replacing
Inc(testcaretpos, Length(Kars));

I don't know what consequences this might have for your navigation using 
the arrow keys, though: I haven't had much experience working with 
multibyte chars.

Hope this helps, anyway.


More information about the Lazarus mailing list