Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2013-07

Memo for touchscreen

12 messages · 4 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Koenraad Lelong

Hi,

For a touchscreen-application (so no real keyboard) I need something like a memo.
I first tried a memo, but how do I enter text at the caret ? And the caretpos is readonly.
Next I tried synMemo, but if I move the caret, the caret disappears. How can I show it ?
How do I send a BackSpace, Delete ?
How do I hide the "rightedge" of the synMemo ? Just set it to the backgroundcolor ?

Is there a better component ?

B.T.W. it will run on linux.

Regards,

Koenraad Lelong.

Reply by email

Kostas Michalopoulos
to Koenraad Lelong

AFAIK this depends on the widgetset and OS configuration. In Windows 7 and 8 (desktop) for example you get a small icon/button at the bottom right of side of the screen that shows a "virtual keyboard" you can use to type stuff.

Koenraad Lelong wrote 26 lines
Hi, For a touchscreen-application (so no real keyboard) I need something like a memo. I first tried a memo, but how do I enter text at the caret ? And the caretpos is readonly. Next I tried synMemo, but if I move the caret, the caret disappears. How can I show it ? How do I send a BackSpace, Delete ? How do I hide the "rightedge" of the synMemo ? Just set it to the backgroundcolor ? Is there a better component ? B.T.W. it will run on linux. Regards, Koenraad Lelong. -- ______________________________**_________________ Lazarus mailing list .**freepascal.org http://lists.lazarus.**freepascal.org/mailman/**listinfo/lazarus<http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20130718/5c9ec496/attachment.html>

Reply by email

waldo kitty
to Koenraad Lelong: For a touchscreen-application (so no real keyboard) I need something like a memo. I…
Koenraad Lelong wrote 13 lines
Hi, For a touchscreen-application (so no real keyboard) I need something like a memo. I first tried a memo, but how do I enter text at the caret ? And the caretpos is readonly. Next I tried synMemo, but if I move the caret, the caret disappears. How can I show it ? How do I send a BackSpace, Delete ? How do I hide the "rightedge" of the synMemo ? Just set it to the backgroundcolor ? Is there a better component ? B.T.W. it will run on linux.

whatever you choose, you appear to need at least some sort of on-screen keyboard component like some (so-called) smartphones have...

NOTE: No off-list assistance is given without prior approval. Please keep mailing list traffic on the list unless private contact is specifically requested and granted.

Reply by email

Malcolm Poole
to Koenraad Lelong: For a touchscreen-application (so no real keyboard) I need something like a memo. I…
Koenraad Lelong wrote 11 lines
For a touchscreen-application (so no real keyboard) I need something like a memo. I first tried a memo, but how do I enter text at the caret ? And the caretpos is readonly. Next I tried synMemo, but if I move the caret, the caret disappears. How can I show it ? How do I send a BackSpace, Delete ? How do I hide the "rightedge" of the synMemo ? Just set it to the backgroundcolor ? Is there a better component ?

TMemo should work - just use SelStart instead of CaretPos.

Try the code below to get you started: Form with a Memo and 2 buttons, named LetterAButton and DeleteButton.

Regards,

Malcolm

//============================================================
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;
procedure TForm1.DeleteButtonClick ( Sender: TObject ) ;
var
   testcaretpos: Integer;
begin
   testcaretpos := Memo1.SelStart;
   Memo1.Text := Copy(Memo1.Text, 1, testcaretpos)
	+ Copy(Memo1.Text, testcaretpos+2, MaxInt);
   Memo1.SelStart := testcaretpos;
   Memo1.SetFocus;
end;

Reply by email

Koenraad Lelong
to waldo kitty: whatever you choose, you appear to need at least some sort of on-screen keyboard…
waldo kitty wrote
On 7/18/2013 07:54, Koenraad Lelong wrote: whatever you choose, you appear to need at least some sort of on-screen keyboard component like some (so-called) smartphones have...

Waldo,

I was working on that.
I also thought of "virtual keyboards", but then the problem arises how to invoke these. I mean, most of the time I don't need a keyboard. But when I need it, how do I pop it up ? Could be as simple as calling the application's name, but then how do I remove it ? I need to study and try. The simplest thing seems making my own virtual keyboard.

Regards,

Koenraad Lelong

Reply by email

Koenraad Lelong
to Malcolm Poole: TMemo should work - just use SelStart instead of CaretPos. Try the code below to get you…
Malcolm Poole wrote 23 lines
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; procedure TForm1.DeleteButtonClick ( Sender: TObject ) ; var testcaretpos: Integer; begin testcaretpos := Memo1.SelStart; Memo1.Text := Copy(Memo1.Text, 1, testcaretpos) + Copy(Memo1.Text, testcaretpos+2, MaxInt); Memo1.SelStart := testcaretpos; Memo1.SetFocus; end;

Thanks,

Works fine, except for navigating up and down. Left and right is OK, I have to find out how to know on what line the cursor is, and then going to the next/previous line, if possible.

regards,

Koenraad Lelong.

Reply by email

Malcolm Poole
to Koenraad Lelong
Koenraad Lelong wrote
Works fine, except for navigating up and down. Left and right is OK, I have to find out how to know on what line the cursor is, and then going to the next/previous line, if possible.

Well I did say it was only to get you started :D

Memo1.CursorPos.y will tell you on which line the cursor is.

Here's a suggestion for navigating to the line above. I'll leave it to you to work out how to navigate to the line below.

Malcolm

==================================

procedure TForm1.UpButtonClick ( Sender: TObject ) ;
var
   newcaretPos: Integer;
   x: Integer;
begin
   newcaretPos := 0;
   writeln(Memo1.CaretPos.Y, #32, Memo1.CaretPos.X);
   for x := 0 to Memo1.CaretPos.Y-2 do
     newcaretPos := newcaretPos + Length(Memo1.Lines[x]) +
Length(LineEnding);
   if Length(Memo1.Lines[Memo1.CaretPos.Y-1]) < Memo1.CaretPos.X
      then newcaretPos := newcaretPos +
Length(Memo1.Lines[Memo1.CaretPos.Y-1]) + 1
      else newcaretPos := newcaretpos + Memo1.CaretPos.X;
   Memo1.SelStart := newcaretPos;
   Memo1.SetFocus;
end;

Reply by email

waldo kitty
to Koenraad Lelong: I was working on that. I also thought of "virtual keyboards", but then the problem arises…
Koenraad Lelong wrote 13 lines
Op 18-07-13 17:32, waldo kitty schreef: > On 7/18/2013 07:54, Koenraad Lelong wrote: > whatever you choose, you appear to need at least some sort of on-screen > keyboard component like some (so-called) smartphones have... > Waldo, I was working on that. I also thought of "virtual keyboards", but then the problem arises how to invoke these. I mean, most of the time I don't need a keyboard. But when I need it, how do I pop it up ? Could be as simple as calling the application's name, but then how do I remove it ? I need to study and try. The simplest thing seems making my own virtual keyboard.

i would think that a button on the main interface that one could tap to bring up the virtual keyboard would be the way to go... then tap that same button to hide the virtual keyboard again... that's likely what i would do if i were in your position... that also based on what little i've interfaced with the two (so-called) smartphones i've ever held for any length of time ;)

NOTE: No off-list assistance is given without prior approval. Please keep mailing list traffic on the list unless private contact is specifically requested and granted.

Reply by email

Koenraad Lelong
to Malcolm Poole: Well I did say it was only to get you started :D Memo1.CursorPos.y will tell you on which…

Op 19-07-13 16:21, Malcolm Poole schreef:
...

Show quoted text 21 lines
================================== procedure TForm1.UpButtonClick ( Sender: TObject ) ; var newcaretPos: Integer; x: Integer; begin newcaretPos := 0; writeln(Memo1.CaretPos.Y, #32, Memo1.CaretPos.X); for x := 0 to Memo1.CaretPos.Y-2 do newcaretPos := newcaretPos + Length(Memo1.Lines[x]) + Length(LineEnding); if Length(Memo1.Lines[Memo1.CaretPos.Y-1]) < Memo1.CaretPos.X then newcaretPos := newcaretPos + Length(Memo1.Lines[Memo1.CaretPos.Y-1]) + 1 else newcaretPos := newcaretpos + Memo1.CaretPos.X; Memo1.SelStart := newcaretPos; Memo1.SetFocus; end;

Hi,

Thanks,
but you're too nice, leave me some homework ! ;-)

Koenraad Lelong

Reply by email

Koenraad Lelong
to Malcolm Poole: TMemo should work - just use SelStart instead of CaretPos. Try the code below to get you…
Op 18-07-13 21:24, Malcolm Poole schreef:
  //============================================================
Show quoted text 13 lines
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;

Hi Malcolm,

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);

Actually, I do this in a procedure with Kars as a parameter.

Any suggestions where to look ?

BTW, I tried this on Lazarus 1.0 on Linux.

Thanks,

Koenraad Lelong

Reply by email

Malcolm Poole
to Koenraad Lelong
Koenraad Lelong wrote 27 lines
> > 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);
by
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.

Malcolm

Reply by email

Koenraad Lelong
to Malcolm Poole
Malcolm Poole wrote 13 lines
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); by 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.

Hi,

Unfortunately, that does not work. I already tried that. The effect is the same.

I think this will not work. Maybe it's better to really simulate keypresses and send these to the application. I remember doing something similar in a Delphi application. I will have to anyway.

Koenraad

Reply by email