Loading ...
Sorry, an error occurred while loading the content.
 

Re: .getAttribute("id") not working for use-elements?

Expand Messages
  • pilatfr
    ... I think that Andreas try to catch id on event, so situation is very different, so I post sample with results for each viewer : (suppose event is on use
    Message 1 of 12 , Oct 18, 2003
      --- In svg-developers@yahoogroups.com, "mathias FATENE"
      <mathias.fatene@w...> wrote:
      > Hi,
      > try to view the value of your object "myElement". This must bve
      > SVGUseElement.
      > I suspect its value !
      > else, it works with asv6 too.

      I think that Andreas try to catch id on event, so situation is very
      different, so I post sample with results for each viewer :
      (suppose event is on use element refering rect element)
      -ASV3
      evt.target is SVGUseElement and we get id of "use"
      - ASV6
      with click or mouseover:
      evt.target is SVGElementInstance and id is not property of this type
      of element
      with mouseout as element has focus, evt.target is SVGUseElement and
      we get id of "use"
      - Batik
      evt.target is SVGRectElement and we get id of "rect"
      From many use elements we get same id but if we change color by
      example, only target is changed ...
      - CSV 2.1
      as in Batik, but all "use" change color

      To change color of one "use" only, it's only possible with ASV6
      (using animatedInstanceRoot - mouseout or correspondingElement -
      mouseover or click ) or Batik (code is same as for other element)

      I forget, example at
      http://pilat.free.fr/temp/test_use.svg

      Michel

      Our tutorial about scripting explore all this "faceties" ....
    • pilatfr
      ... free.fr seems out ... Try http://pilat.ouvaton.org/temp/test_use.svg Michel
      Message 2 of 12 , Oct 18, 2003
        > I forget, example at
        > http://pilat.free.fr/temp/test_use.svg

        free.fr seems out ...
        Try
        http://pilat.ouvaton.org/temp/test_use.svg

        Michel
      • mathias FATENE
        Merci Michel. I think that the difference is not just catching event (in the onload example, its also caching, or not ?). The example is that your orange rect
        Message 3 of 12 , Oct 18, 2003
          Merci Michel.

          I think that the difference is not just catching event (in the onload
          example, its also caching, or not ?).
          The example is that your orange rect event will not be catched (ASV6) if the
          event is mouseover.

          The difference is due to the scalability of SVG1.2 in catching events not
          according to SVBG1.1. It respects more the Batik's one. Will we ask
          ourselves with ASV6 before treating an event, if this event is click,
          mouseover ou mouseout ? And then
          apply getCorrespondingUseElement() or getCorrespondingElement() ... or what
          ?

          so must we write in every function
          if "("event" == "mouseout")" <=== algo
          else ...
          ????
          should i prepare migration ASV3 -> ASV6 or what's the trick ?

          Mathias

          -----Message d'origine-----
          De : pilatfr [mailto:pilat@...]
          Envoyé : samedi 18 octobre 2003 10:32
          À : svg-developers@yahoogroups.com
          Objet : [svg-developers] Re: .getAttribute("id") not working for
          use-elements?


          --- In svg-developers@yahoogroups.com, "mathias FATENE"
          <mathias.fatene@w...> wrote:
          > Hi,
          > try to view the value of your object "myElement". This must bve
          > SVGUseElement.
          > I suspect its value !
          > else, it works with asv6 too.

          I think that Andreas try to catch id on event, so situation is very
          different, so I post sample with results for each viewer :
          (suppose event is on use element refering rect element)
          -ASV3
          evt.target is SVGUseElement and we get id of "use"
          - ASV6
          with click or mouseover:
          evt.target is SVGElementInstance and id is not property of this type
          of element
          with mouseout as element has focus, evt.target is SVGUseElement and
          we get id of "use"
          - Batik
          evt.target is SVGRectElement and we get id of "rect"
          From many use elements we get same id but if we change color by
          example, only target is changed ...
          - CSV 2.1
          as in Batik, but all "use" change color

          To change color of one "use" only, it's only possible with ASV6
          (using animatedInstanceRoot - mouseout or correspondingElement -
          mouseover or click ) or Batik (code is same as for other element)

          I forget, example at
          http://pilat.free.fr/temp/test_use.svg

          Michel

          Our tutorial about scripting explore all this "faceties" ....





          -----
          To unsubscribe send a message to: svg-developers-unsubscribe@yahoogroups.com
          -or-
          visit http://groups.yahoo.com/group/svg-developers and click "edit my
          membership"
          ----

          Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
        • pilatfr
          ... onload ... (ASV6) if the ... For mouseover with ASV6, evt.target is as for click SVGElementInstance I only write what happend ... I don t know if it s
          Message 4 of 12 , Oct 18, 2003
            --- In svg-developers@yahoogroups.com, "mathias FATENE"
            <mathias.fatene@w...> wrote:
            > Merci Michel.
            >
            > I think that the difference is not just catching event (in the
            onload
            > example, its also caching, or not ?).
            > The example is that your orange rect event will not be catched
            (ASV6) if the
            > event is mouseover.

            For mouseover with ASV6, evt.target is as for click
            SVGElementInstance

            I only write what happend ...

            I don't know if it's correct that type for evt.target will not be
            same if element has focus or not?

            If it's, to migrate to ASV6, we have to be very carefull !!!

            Michel
          • mathias FATENE
            Thanks Michel. I was confused by the type of event s changes, according to the ASV version. BVut till now, ASV6 is beta. Maybe it will change. mathias ... De :
            Message 5 of 12 , Oct 18, 2003
              Thanks Michel. I was confused by the type of event's changes, according to
              the ASV version.
              BVut till now, ASV6 is beta. Maybe it will change.

              mathias

              -----Message d'origine-----
              De : pilatfr [mailto:pilat@...]
              Envoyé : samedi 18 octobre 2003 15:01
              À : svg-developers@yahoogroups.com
              Objet : [svg-developers] Re: .getAttribute("id") not working for
              use-elements?


              --- In svg-developers@yahoogroups.com, "mathias FATENE"
              <mathias.fatene@w...> wrote:
              > Merci Michel.
              >
              > I think that the difference is not just catching event (in the
              onload
              > example, its also caching, or not ?).
              > The example is that your orange rect event will not be catched
              (ASV6) if the
              > event is mouseover.

              For mouseover with ASV6, evt.target is as for click
              SVGElementInstance

              I only write what happend ...

              I don't know if it's correct that type for evt.target will not be
              same if element has focus or not?

              If it's, to migrate to ASV6, we have to be very carefull !!!

              Michel



              -----
              To unsubscribe send a message to: svg-developers-unsubscribe@yahoogroups.com
              -or-
              visit http://groups.yahoo.com/group/svg-developers and click "edit my
              membership"
              ----

              Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
            • neumannandreas
              stupid, that I did not provide an example - here it is: http://www.karto.ethz.ch/neumann/temp/use_id_test.svg in ASV3 it works, in ASV6 it says object doesn t
              Message 6 of 12 , Oct 18, 2003
                stupid, that I did not provide an example - here it is:

                http://www.karto.ethz.ch/neumann/temp/use_id_test.svg
                in ASV3 it works, in ASV6 it says "object doesn't support this method", in CSV2.1 and
                Batik it doesn't give the correct value back.

                I use a symbol and symbol instance and then use evt.target.

                yes - I think Michel described exactly the problem I ran in.

                What would you suggest? Of course I can implement my checkBox different now -
                maybe using siblings in the group - but somehow this is annoying that the viewers
                behave different there.

                Don't know what is the correct behaviour anyway ...

                Andreas


                --- In svg-developers@yahoogroups.com, "Doug Schepers" <doug@s...> wrote:
                > Hi, Andreas-
                >
                > It works fine for me on WinXP/IE6 + ASV3/ASV6p1/CSV2.1. I use the
                > "getAttributeNS" code in the following code, but "getAttribute" worked fine,
                > too.
                >
                > I'm not sure what your problem can be... What's your environment?
                >
                > <svg onload='Init(evt)'>
                > <script type='text/ecmascript'><![CDATA[
                > var SVGDocument = null;
                > var SVGRoot = null;
                > function Init(evt)
                > {
                > SVGDocument = evt.target.ownerDocument;
                > SVGRoot = SVGDocument.documentElement;
                > myUse = SVGDocument.getElementById('myUse');
                > alert(myUse.getAttributeNS(null, 'id'));
                > }
                > ]]></script>
                > <rect id='myRect' x='5' y='5' width='15' height='15' style='fill:red' />
                > <use id='myUse' x='50' y='50' xlink:href='#myRect' />
                > </svg>
                >
                > Regards-
                > -Doug
                >
                >
                > neumannandreas wrote:
                > > Hi!
                > >
                > > I have a use-element that has an "id" attribute set.
                > >
                > > However, when I use
                > >
                > > myText = myElement.getAttribute("id");
                > >
                > > it only works in ASV3 - it doesn't work in ASV6, nor in CSV2.1 nor in
                > Batik?
                > >
                > > Any idea why this should not work. Is it not allowed to use "id" on
                > use-elements?
                > >
                > > Thanks,
                > > Andreas
              • Jim Ley
                neumannandreas wrote in message news:bmrnnk+pmsa@eGroups.com... ... now - ... viewers ... ASV6pr appears to be correct to me, an
                Message 7 of 12 , Oct 18, 2003
                  "neumannandreas" <neumann@...> wrote in message
                  news:bmrnnk+pmsa@......

                  > What would you suggest? Of course I can implement my checkBox different
                  now -
                  > maybe using siblings in the group - but somehow this is annoying that the
                  viewers
                  > behave different there.
                  >
                  > Don't know what is the correct behaviour anyway ...

                  ASV6pr appears to be correct to me, an ElementInstance should be returned, I
                  don't believe any user agents before 6 had implemented this, and it's rather
                  disappointing that users are running into problems now (all features of the
                  1.0 / 1.1 spec should've been implemented in some UA before it left PR!)

                  To cope with the different UA's you have to switch on the type of evt.target
                  and normalise it back to what you want, it's a pain, but then all versioning
                  in javascript is a pain, and object detection is the only realisitic
                  solution proposed in the HTML world.
                  var element = evt.target;
                  if (element.correspondingUseElement)
                  element=element.correspondingUseElement
                  else {
                  // We're on Batik or CSV, and I don't know
                  // a way to get to the USE element
                  // You can use the nodeName of element to identify
                  // the non-USE people
                  // What you actually do then I'm not sure.
                  }
                  var myId = element.getAttributeNS(null,"id");
                  alert ("id: "+myId+", element-type: "+element);
                  }

                  However for a checkbox I would not recommend a USE, the animatedInstanceRoot
                  is just too much of a mess IMO, and has only the one beta implementation.
                  I'm afraid inserting them multiple times is the only realistic approach.
                  This mess was the motivation behind my recent CLONE suggestion on www-svg.

                  Jim.
                • pilatfr
                  ... different now - ... that the viewers ... If you have not too many symbols, you can on event send parameter, so you don t need id. Michel
                  Message 8 of 12 , Oct 18, 2003
                    --- In svg-developers@yahoogroups.com, "neumannandreas"
                    <neumann@k...> wrote:
                    > What would you suggest? Of course I can implement my checkBox
                    different now -
                    > maybe using siblings in the group - but somehow this is annoying
                    that the viewers
                    > behave different there.

                    If you have not too many symbols, you can on event send parameter,
                    so you don't need id.

                    Michel
                  • neumannandreas
                    ... yes - exactly, that s what I did now - it works fine for my checkboxes. But I can imagine other cases where I would need the ID for my symbol instances.
                    Message 9 of 12 , Oct 18, 2003
                      --- In svg-developers@yahoogroups.com, "pilatfr" <pilat@w...> wrote:
                      > --- In svg-developers@yahoogroups.com, "neumannandreas"
                      > <neumann@k...> wrote:
                      > > What would you suggest? Of course I can implement my checkBox
                      > different now -
                      > > maybe using siblings in the group - but somehow this is annoying
                      > that the viewers
                      > > behave different there.
                      >
                      > If you have not too many symbols, you can on event send parameter,
                      > so you don't need id.

                      yes - exactly, that's what I did now - it works fine for my checkboxes. But I can
                      imagine other cases where I would need the ID for my symbol instances. Imagine
                      having symbols in maps for point-features, where the ID plays a relevant role in
                      linking to other data. There is most always a work-around, but it is not very elegant.

                      Andreas
                    Your message has been successfully submitted and would be delivered to recipients shortly.