Style attribute in a style element

  • Hi,

    I do find it's always annoying to apply several styles to a single element. Example :

    Code
    <hotspot name="whatever" style="style1|style2" ... />


    Especially as I have half my hotspots with 'style1|style2' and the other half with 'style1|style3'. (style1 is like some base style to apply to all my hotspots)


    Krpano documentation says it's possible to have a style in any xml element.

    Let's try inheritance of styles then :


    Code
    <style name="style1" ... />
    <style name="style2" style="style1" .../>

    I would expect that if I apply "style2" somewhere, both "style1" and "style2" would be applied, just like style1|style2.


    So I tested


    Code
    <style name="style1" ... />
    <style name="style2" style="style1" .../>
    <hotspot name="whatever" style="style2" .../>


    and ... it works! "style2" seems to be now working just like a "style1|style2"! => GREAT !


    However, when tracing the hotspot.style content with a simple "trace(hotspot[whatever].style)", it gives me "style1" !?!? it should give me style="style2" for things to be right, as it's what I entered in the xml.

    Is the kind of style inheritance I'm doing supported ? or is it just working "zum Glück"...it's what I suspect...


    Thanks
    PS: it's so close to working fine! just that trace(hotspot[].style) not working...

  • Hi,

    that 'style' attribute is a special feature of the xml parser from krpano and works like this:
    - when a xml element has a style attribute, then all attributes of the related <style> are copied to that xml element

    See also here:
    https://krpano.com/docu/xml/#style

    That means in your case, all attributes from style1 are copied to style2 and so style2 contains both.

    Best regards,
    Klaus

  • Thanks. I get the point, so it means what I'm doing is not supported.


    Else it should work differently for the style attribute itself, as we have some really weird stuff at the end:

    in the xml

    Code
    <hotspot name="whatever" style="style2"/>

    at the end:

    Code
    trace(hotspot[whatever].style) : "style1"

    (not really true is it?)

    I asked for a style2 hotspot and what I finally have is a style="style1" one (with attributes from style2 though). If I decide to loop on all style2 hotspots, I won't find any, only style1 everywhere!

    Would you have a way round to have at the end trace(ht.style) = "style2" as what I asked for in the xml ?

    Thanks
    (I could do a <hotspot name="whatever" style="sup" realstyle="sup"/>, and onxmlcomplete I could loop on all hotspots/layers and replace style by realstyle...but it looks dirty doesn't it?)

Participate now!

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