Question about Tech Tip: Get the best display width and height for the given text data


There is a tech tip about how one can determine the best width and height for text when using dynamic forms:

We use dynamic forms where the user can construct his own form, and is able to create for example multi-styled instruction texts. This could potentially lead to tens of multi-styled texts

Because I want to know the best height of these texts I want to use the technique in the tech tip
This technique uses a dialog to calculate the best size

My question:
Could there be a performance issue when calling the TEXT_GET_DISPLAY_BEST_SIZE method a lot of times?

Hi Piotr,
nice tip…
I have no idea at all, and no time to try right now, but I would not be surprised that the time to open/close the window is not negligible.
If it happens to be slow, it seems possible from that code to replace c_text($1) with something like c_collection($1) in which N items are N texts. Then you could loop on these N text without re opening the form N times.

Hi, I think c_collection($1) is a nice tip :grinning:

Finally I tried, I couldn’t resist…

Schematically, if I call the method:

  • 20 times for 20 texts, I have 20 ugly repeated flashes on the screen and it takes ~3seconds
  • once with a collection of 20 texts, still one flash and 196ms

As we say in french, “mass has been said”…

I was wondering 2 things,

  • why the method calls “open window” and not “open form window”: such a form cannot have a name?
  • if the window type can influence the display (here with missing parameter, the command uses a modal one)

? Google traduction me donne : la masse a été dite
Je ne connaissais pas cette expression ? :rofl:

Hi Arnaud,

Thanks for the research, and your solution looks good
However, unfortunately, I don’t like flashes and so don’t my customers I think :pensive:
So while it is an interesting tech tip, I find it not a real solution
I think I saw a tech tip to accomplish things using SVG
The problem is that I need styled-text objects

And what if you used a 4D Write Pro zone ?

When I wrote, I forgot to say, hide process/do the job/show process = no flash.

I’m not sure svg text and styled text have the same characteristics, this should be checked first.

prions mes frères pour que google traduction ne soit pas à la masse :pray:

We want the full functionality that forms can deliver, including form methods, object methods, checkboxes, 3d buttons etc. So Write Pro in this case is no solution for this


I think you don’t understand my proposition :confused:
It’s only to:

not for use as a complet form.
And as 4D Write Pro allows the offscreen = no flash

Thinking about “what process could do this”: if your main process is hidden, and knowing it’s a worker, it’s worth trying to make it execute that job (call worker(1)).

Ok, you’re right I did not understand it that way
So you are saying I can create a Write Pro object, insert the styled text, get the best width/height by some commands, and drop the Write Pro object?

That’s the idea but,
It’s just an idea, don’t know if this can resolve your demand but with this command
WP Get position and the rangeHeight property name returned, I think you can have the Height of you styled text.

1 Like

That’s very clever. You’d need a WP license for that, so perhaps a “polyfill” would be nice.