Keeping the XControl’s text size proportional to the object’s size.

Question:

How can I keep an XControl‘s Text size proportional to a Figure size?

 

 

 

Solution:

To do so, you must change the Size hidden subproperty of the Text’s TextFont property. This can’t be accessed via AppBrowser, just via scripts:

‘this line changes text size
Screen.Item(“Text1”).TextFont.Size = 36

To set up this property, you have to create a formula that sets the proportion via scripts. For example:

‘Width of the reference-object
w = Item(“Figure1”).Width

‘Formula
NewSize = w / 75

‘Font’s value
Item(“Text1”).TextFont.Size = int(NewSize)

In this example, an object whose width is equal to 1000 has a text whose size equal to 13.

You can also create a property in the XControl and add it to the Formula in this script, allowing the user to configure the text’s size:

‘Formula
NewSize = w * TextProportion / 75

Now, when setting up TextProportion property to 1.2, the text’s size will be set up to 16 (taking into consideration that the width is equal to 1000).


Where can I execute this script?

To execute the script, you can insert it in the XControl’s CustomConfig event. Set up XControl’s CustomConfigText property as desired. For example:

 

 

 

As the result, we have a Text that is proportional to the instance’s size:

 

 

 

NOTES:

  1. The text displayed in E3Studio is just an example. To keep this size when executing the application, you must insert the same script in the XControl’s OnStartRunning event.
  2. Attached to this article is a demo application.

 

Attachments:

ProjXCproporcional_en.zip

Print Friendly, PDF & Email

Este artigo foi útil? Was this helpful?

Classificação média - Average rating 0 / 5. Count: 0

Leave a Reply

Your email address will not be published.Required fields are marked *