Re: [Lazarus] Memo for touchscreen

2013-08-28 Thread Koenraad Lelong

Op 27-08-13 18:50, Malcolm Poole schreef:

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 look at that.


Thanks anyway.

Koenraad

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Memo for touchscreen

2013-08-27 Thread Malcolm Poole

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



--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Memo for touchscreen

2013-08-26 Thread Koenraad Lelong

Op 18-07-13 21:24, Malcolm Poole schreef:
 //


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


--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Memo for touchscreen

2013-07-20 Thread Koenraad Lelong

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


==

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

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Memo for touchscreen

2013-07-19 Thread waldo kitty

On 7/19/2013 03:19, Koenraad Lelong wrote:

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.

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Memo for touchscreen

2013-07-19 Thread Malcolm Poole

On 19/07/13 13:45, 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;




--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Memo for touchscreen

2013-07-19 Thread Koenraad Lelong

Op 18-07-13 21:24, Malcolm Poole schreef:
>
> 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.


--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Memo for touchscreen

2013-07-19 Thread Koenraad Lelong

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.


Regards,

Koenraad Lelong


--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Memo for touchscreen

2013-07-18 Thread Malcolm Poole

On 18/07/13 12:54, Koenraad Lelong wrote:

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;



--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Memo for touchscreen

2013-07-18 Thread waldo kitty

On 7/18/2013 07:54, Koenraad Lelong wrote:

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.

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Memo for touchscreen

2013-07-18 Thread Kostas Michalopoulos
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.


On Thu, Jul 18, 2013 at 1:54 PM, Koenraad Lelong
wrote:

> 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
> Lazarus@lists.lazarus.**freepascal.org
> http://lists.lazarus.**freepascal.org/mailman/**listinfo/lazarus
>
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


[Lazarus] Memo for touchscreen

2013-07-18 Thread 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.

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus