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
 Limit the size of a text layer

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
[Redacted]
4   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
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
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
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