LEADTOOLS Support
General
General Questions
Dynamically resize text annotation while typing
#1
Posted
:
Monday, October 15, 2018 7:21:08 AM(UTC)
Groups: Registered
Posts: 1
Hello,
we are using annotations and let our users create them in our software written in C#. When working with text annotations such as AnnTextObject we can utilize the AnnTextEditDesigner to allow user input directly on the document.
Is there a way to let the text input (and the underlying AnnTextObject) dynamically resize while the user is typing? There is the property autoSizeAfterEdit, but it only applies after edit as the name suggests, offers little flexibility how to resize and in my test did not resize at all (maybe I'm missing something here as I'm new to LEADTOOLS). Ideally we would like to have the AnnTextObject grow to the right and downwards as needed as the text reaches the borders.
We tried to do the resize ourselves, but it seems neither the keydown event of the AnnTextEditDesigner nor of the RasterImageViewer gets fired when typing text into the annotation and then there could also be changes issued via mouse. Are we missing something, or is this not possible using the AnnTextEditDesigner?
#2
Posted
:
Monday, October 15, 2018 8:25:00 AM(UTC)
Groups: Registered, Tech Support, Administrators
Posts: 199
Was thanked: 28 time(s) in 28 post(s)
Hello,
Unfortunately the text box you actually type into is a native text box, specifically the Leadtools.Annotations.Winforms.AutomationTextBox. In order to resize the text box while you're typing you'd need to hook into the
TextChanged event of that text box. Alternatively you can add to the existing
OnKeyPress or
OnPreviewKeyDown event handlers.
The source for that text box can be found in the following file:
LEADTOOLS 20\Examples\DotNet\CS\Leadtools.Annotations.Winforms\UI\Controls\AutomationTextBox.cs
Note, you'll need to rebuild the Leadtools.Annotations.Winforms assembly, then rebuild your own project before any changes will take effect.
For calculating the size the text box needs to be, you'll want to use the MeasureString method (and possibly inflate by 12x12 like the original AutomationTextBox does in the constructor:
https://www.leadtools.com/help/leadtools/v20/dh/ac/annrenderingengine-measurestring.htmlThanks,
Anthony Northrup
Developer Support Engineer
LEAD Technologies, Inc.
LEADTOOLS Support
General
General Questions
Dynamically resize text annotation while typing
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.