ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 layer size text

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

View 
UserName:
Password:
Format  Bold Italicized Underline  Align Left Centered Align Right  Horizontal Rule  Insert Hyperlink   Browse for an image to attach to your post Browse for a zip to attach to your post Insert Code  Insert Quote Insert List
   
Message 

 

Emoji
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Black Eye [B)]
Frown [:(] Shocked [:0] Angry [:(!] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
AndNit 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
9   L A T E S T    R E P L I E S    (Newest First)
xequte Posted - Sep 02 2024 : 17:36:32
Please see:

https://docwiki.embarcadero.com/Libraries/Athens/en/Vcl.Graphics.TCanvas.TextExtent

Nigel
Xequte Software
www.imageen.com
AndNit Posted - Sep 02 2024 : 15:12:36
How can I calculate the width and height of the text using Canvas?
xequte 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 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 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 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 Posted - Jun 07 2024 : 16:13:19
Hi

There is no built in functionality for that. You would need to reset the Key parameter of the TImageEnView.OnTextEditorKeyDown event:

https://www.imageen.com/help/TImageEnView.OnTextEditorKeyDown.html

Nigel
Xequte Software
www.imageen.com
AndNit 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.
AndNit 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.