Author |
Topic |
|
AndNit
Brazil
81 Posts |
Posted - Jun 07 2024 : 12:48:09
|
Good afternoon,
I have a text layer with predefined size X, Y, Width and Height. I can only type on this layer, up to its limit. How to identify that you have reached the end of it and prevent the user from continuing typing?
Thanks |
|
AndNit
Brazil
81 Posts |
Posted - Jun 07 2024 : 14:47:35
|
I don't know if I understood you correctly, sorry.
I would like the user to be able to type only up to the maximum size of the text layer, in height and width. Not allowing it to increase or decrease the layer. |
|
|
AndNit
Brazil
81 Posts |
Posted - Jun 07 2024 : 14:53:26
|
As if it were Word, when it reaches the end of the line, it skips the line, and when it reaches the end of the page, it skips the page, in this case, I need to know when the text reached the end of the layer (Width X Height)
for vertical, I use WordWrap = True, which automatically wraps the line, but for vertical, there is nothing that tells me the end of the Layer. |
|
|
xequte
38439 Posts |
|
AndNit
Brazil
81 Posts |
Posted - Jun 07 2024 : 16:21:58
|
I was seeing this event, I managed to understand how it works, but I can't imagine how to change the Key parameter, to identify the end of the text layer. Can you help me with some way?
Thanks |
|
|
xequte
38439 Posts |
Posted - Jun 07 2024 : 21:03:40
|
Hi
Here is a better method:
// Prevent user from entering too much text
procedure Tfmain.ImageEnView1LayerNotifyEx(Sender: TObject; layer: Integer; event: TIELayerEvent);
const
Maximum_Text_Length = 10;
var
editor: TIEEdit;
pos: Integer;
s: string;
begin
if ( Maximum_Text_Length > 0 ) and ( event = ielTextEditorChange ) then
begin
if ImageEnView1.LayersTextEditor is TIEEdit then
begin
editor := TIEEdit( ImageEnView1.LayersTextEditor );
if Length( editor.Text ) > Maximum_Text_Length then
begin
pos := editor.SelStart;
s := editor.Text;
SetLength( s, Maximum_Text_Length );
editor.Text := s;
editor.SelStart := pos;
end;
end;
end;
end;
Nigel Xequte Software www.imageen.com
|
|
|
AndNit
Brazil
81 Posts |
Posted - Jun 08 2024 : 05:38:31
|
Firstly thanks for the help, but it seems that this way I limit the text by the number of letters and I needed to limit it by the space of the text layer, which in each situation will be of a different size, I don't have the total number of words in advance. |
|
|
xequte
38439 Posts |
Posted - Jun 10 2024 : 00:23:45
|
Hi
Yes, there is not really an easy way to do that, unfortunately.
If the text layer has AutoSize enabled, then you could check the TextEditor width and height and if its too big, delete the last character. Alternatively calculating the width and height of the text yourself (i.e. using Canvas.TextWidth/TextHeight).
Nigel Xequte Software www.imageen.com
|
|
|
AndNit
Brazil
81 Posts |
Posted - Sep 02 2024 : 15:12:36
|
How can I calculate the width and height of the text using Canvas? |
|
|
xequte
38439 Posts |
|
|
Topic |
|