B4J Question Node min width and height

PatrikCavina

Active Member
Licensed User
Longtime User
Hi to all,
I would to know if there is a way to calculate min width and min height of node, based to its content (like a text).
 

Cableguy

Expert
Licensed User
Longtime User
You could try to set them to -1, which will make them autofit to contents and then retrieve those values...
( never tried, not sure it will work as expected)
 
Upvote 0

PatrikCavina

Active Member
Licensed User
Longtime User
I've already tried, but this isn't what i'm looking for.
I need calculate it without testing (in this case resizing to watch the result)
 
Upvote 0

Cableguy

Expert
Licensed User
Longtime User
you could do it in a hidden node... (?)
 
Upvote 0

PatrikCavina

Active Member
Licensed User
Longtime User
Content can be any type, because my class should be applied to all kind of nodes.
So calc only text size isn't sufficient.
Using hidden node could be an idea, but to apply changes to hidden node i'll need to call a sleep(0) and take the result.
But i don't like too much this solution.

Moreover for using a hidden node I need to clone the existing node, to get its properties.
 
Last edited:
Upvote 0

Cableguy

Expert
Licensed User
Longtime User
Can you elaborate on what exactly you need to achieve?
Maybe propose a real case scenario for better understanding
 
Upvote 0

PatrikCavina

Active Member
Licensed User
Longtime User
I want reproduce the resize frame like in visual designer at runtime, where Resize Frame is a class that accept any type of node and create a frame around it.

Immagine.png

My approch it was creating a Base around passed node, where inside the base there are:
indicators that are panes;
transparent pane with border that reproduce the frame.

Immagine2.png

Order of resizing is:
1) Base
2) Transparent Base (in function of Base)
3) Passed Node (in function of Transparent Base)

Everythings work but, for example in this case, if i change the text size of button or the font, node min size are changed according to his content.
So i should set min size when resizing and stop the frame resizing when node is not longer resizable, otherwise the result will be:

Immagine3.png

Using the text size calculation would limit me to using the class only with nodes containing text.
I hope my problem is clearer.
 
Upvote 0

Cableguy

Expert
Licensed User
Longtime User
Why not use the size changed event? ( can' recall the exact name of it)
 
Upvote 0

PatrikCavina

Active Member
Licensed User
Longtime User
Because, resize event of passed node is handle from the module or class that have initialize it.
If you was talking about of that
 
Upvote 0
Top