how to get the width of a textlayer and copy it

  • dear forummembers

    how to read out the width of this textfield see the code below and copy it to it's parent layer[primus]



    Code
    <layer name="subtext" style="leo2"
    			html="hier können sie mehr über die[br]
    				  mittelalterliche Uferbefestigung erfahren"		 
    			parent="layer[primus]"
    			align="leftbottom" ox="0"	   
    			onclick=""/>
  • Hi,

    there are multiple ways:

    With version 1.21 this can be done automatically by adding flowchildren="v" (and optionally also a childmargin) to the parent layer. Then the parent layer will take the size of its children:

    Code
    <layer type="container" ... flowchildren="v" childmargin="5">
       <layer type="text" ... />
    </layer>

    Or use the onresize event (also version 1.21) on the inner layer and transfer the size back to the parent (plus optionally some adjustments):

    Code
    <layer ... onresize="parentobject.width = width + 10;" />

    Best regards,
    Klaus

  • Hello Klaus. can i also read out the lowest layer in a hierarchy and bring this value to the parent.
    for example the value from text2 (see code below)


    Code
    <layer type="container" ... flowchildren="v" childmargin="5">
       <layer type="img" ... >
       <layer type="vector" ... >
       <layer type="text1" ... >
       <layer type="text2" ... />
    </layer></layer></layer>

    Edited once, last by nikonutsch (February 8, 2023 at 3:51 PM).

  • dear forummembers

    i have had a lot of questions in the last days
    svg hotspots , getlooktodistance and now the problem with bringin child value to the parent.

    i ll show an example on what i am working.
    ( i have bought a license for callout hotspots, but ei want to have a bit more control, so i started to try.......)


    https://360.tirol/bw/

    finaly i want to get the sice of the masklayer depending to its child_parts

  • Hello Klaus. can i also read out the lowest layer in a hierarchy and bring this value to the parent.

    You could loop through parentobject until it is null, but when you know the hierarchy, it might easier just to use e.g.
    parentobject.parentobject.parentobject.width = ...;
    to go a certain steps upward...

    *thumbup*

    finaly i want to get the sice of the masklayer depending to its child_parts

    What is the masklayer in this example?

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!