assignstyle(elementname, styles, *keep) - [Suggestion]

  • dear klaus,

    a while ago we talked about adding styles with .loadstyle() to custom elements,
    or elements not having loadstyle() now, and you said something like that wouldn't be so easy
    because of protected properties, etc.
    i forgot about it then, but a few days ago you mentioned assignstyle()
    in some thread after some experiments...

    it seems to me that assignstyle() is great, but copies the styles properties to the destination
    without respecting existing values and so doesnt behave like the "normal" styles.

    so now my suggestion:
    wouldnt it be relatively easy to implement this with assignstyle(elementname, styles, *keep);
    while keep = true just would not copy style properties which are already present on the element.
    keep would be optional and default to false so that exiting code doesn't break.

    gosh that would allow some dynamic beauty in my code!
    ;)

    best index
    @1.19-pr6

  • 2 yrs later i ran in to the same problems and searching brought up my own post *g*

    it would be really nice to be able to replicate the normal style behaviour from scripting...
    (not overwriting existing values)

    ... and EDIT ... why not do it myself ...

    it is kind of a trick/hack and
    and it might not work properly with krpano < 1.19pr15,
    but for my purpose (on scenes and layers) it seems to work

    Klaus ... what do you think of it?

  • Hi,

    an interesting solution with using a temporary object *thumbup* ...
    ... but it could only add new properties, coping the property only when it wasn't manually set yet is also not possible this way (and I thought this was the request also about).

    Best regards,
    Klaus

  • hey :)
    that works, i use it that way...
    1) assign styles to temp --> temp has all attributes of the styles
    2) copy destination to temp --> that overwrites all existing attributes of destination in temp
    3) copy temp to destination --> dest has its original attributes plus the not existing ones from the styles

    ... its a bit clumsy, but works ...
    altough.. it would be cool to have that built in...
    *rolleyes*

    ps. in xml that would be:

    Code
    assignstyle(assignstyle[tmp], mystyle1|mystyle2|mystyle2);
    copyattributes(get(assignstyle[tmp], get(layer[test]));
    copyattributes(get(layer[test]), get(assignstyle[tmp]);
    delete(assignstyle[tmp]);


    (assign styles mystyle1|mystyle2|mystyle2 to layer[test] while keeping all existing attributes)

Participate now!

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