If you have your text formatted somewhere you could check the lenght of one line and therefore know the width of the box. If you use the text blitter object you know how many pixels each character has and then resize the frame. The height of the box could be determined by the number of lines that your text has. This way you will know the exact size of the text block.
Another idea: create an invisible 1px object where the text starts then blit the text. After that create another 1px object when text is done. Coordinates of those two objects define the rectangle. This only works if the last line is the longest otherwise define your own new line and remember the x position.
Thanks for the reply! I ended up with another solution though - if anyone is instersted or have feedback on this method to perhaps make it better I'd love to hear:
1. I used an Active System Box object for the text string, as it gives much more control on how it looks and what you can do with it, and I set it to be at the size of the frame so it will show in the middle of the screen no matter the amount of text I set it to show.
Please login to see this attachment.
In this example I gave the text a yellow background to show that the object is set at the size of the entire screen. It is positioned at 0 on both X and Y axis.
2. I added the Calculate Text Rect object which lets you calculate the actual width and height of the Active System Box object (I suppose it works on other string objects too) while disregarding all the empty space around the text which fills the entire screen.
Please login to see this attachment.
This screenshot shows how the Calculate Text Rect object affects the Active System Box object, which behaves like cropping the empty bounding box area around the text of the Active System Box object.
3. I made 4 corner piece objects for the custom frame that I wish to surround the text with, and set an always event to position them around the Active System Box object, which with the help of the Calculate Text Rect object aligns them to be around the actual text and not around the entire bounding box of the Active System Box object which would have been off-screen in this case.
Please login to see this attachment.
The custom frame object pieces I used in this example are quite simple - just 8x8 object pieces with a black line and white background to give some space for the text from the edges of the frame.
4. Then I needed 4 additional frame piece objects to fill the gap between the corner pieces and close the frame. The scale size of these objects should be dynamic, which will scale up or down depending on the amount of text that makes the overall size of the entire block of text. So I then made 4 additional frame piece objects which are Left, Right, Top and Bottom. I positioned the Top and Bottom pieces to the right edge of the Top Left Corner piece, and the Left and Right pieces to the bottom of the Top Left Corner Piece; I set their hot spots to their opposite side as I wish the scale operation to occur from their opposite direction.
Please login to see this attachment.
In this screenshot the 4 additional frame piece objects are paint in red so you could see and distinguish them.
5. And lastly, I used @almightyzentaco's "360 Laser Tutorial for Clickteam Fusion 2.5" fast loop method (Please login to see this link.) to make the Top, Bottom, Left and Right frame piece objects increase their size until they collide with the opposite frame corner object piece which breaks the fast loop; the Top and Bottom pieces has their own fast loop and the Left and Right pieces has their own as well.
Please login to see this attachment.
This is how the scale operation looks.
The end result looks like this (forgot to remove the yellow background):
Please login to see this attachment.
And you can of course change the decoration of the frame pieces to whatever you like and change the amount of text freely and the frame objects will be relative to the overall size of the block of text:
Please login to see this attachment.
Please login to see this attachment.