Beschriftung per Skript ausblenden und Anderes klappt nicht

FriedrichLaher shared this question 2 years ago
Needs Answer

in der Demo die Punkte Mßx , A , B klicken ( Mßx muß der erste sein ) .

leider scheint der Code der Zeile 61 folgt und die Beschriftungen ausblenden, fir Strichdicken ändern und anderes sollte, wirkungslos .

{
  const
  evcm = ggbApplet.evalCommand,
  RGL = ggbApplet.registerClickListener,
  uRGL = ggbApplet.unregisterClickListener
  ;
  if (localStorage.getItem('laherBemaszerZaehler') == null)
  localStorage.setItem('laherBemaszerZaehler', 0)
  ;
  zlr = localStorage.getItem('laherBemaszerZaehler')

  RGL('Target1st');
  // -----------------------------------------------------------------
  function NoMszxBemaszung() {
    alert('Mßx zu bemaßen nicht vorgesehen;\n\
           Bitte vorhandenen Punkt klicken oder neuen setzen.'
    );
  } // ----------------------------------------------------------------
  function Target1st(obj) {
    uRGL('Target1st');
    if ('Mßx' == obj)
    {
      NoMszxBemaszung();
      return
    }
    localStorage.setItem('laherBemaszer1stObj', obj);
    RGL('Target2nd');
  } // -----------------------------------------------------------------

  function Target2nd(obj) {
    uRGL('Target2nd');
    if (((pktL = localStorage.getItem('laherBemaszer1stObj') // gewählter Punkt
    ) == obj)                                             // identisch mit dem
    || obj == 'Mßx'                                      // 1tem oder "Mßx"
    )
    {
      if (!condirm('2ter Punkt muß verschieden von 1tem sein.\n\
                   Wenn Du nun nichr abbrichst ist der näcgtte\n\
                   geklickte PJunkt ein "erster".')
      ){
          RGL('Target1st'); return;
      }
    }
    zlr = localStorage.getItem('laherBemaszerZaehler');

    evcm('PfP' + zlr + '= Point( PerpendicularLine(' + pktL + ',' + 'Segment(' + pktL + ',' + obj + ') ) )'
    );
    evcm('hght' + zlr + '= Point( PerpendicularLine(' + obj + ',' + 'Segment(' + pktL + ',' + obj + ') ) )'
    );
    evcm('BlR' + zlr + '= Segment(' + obj + ',' + 'hght' + zlr + ')'
    );
    evcm('BlL' + zlr + '= Translate(BlR' + zlr + ',' + 'Vector(' + obj + ',' + pktL + '))'
    );
    evcm('PfPr' + zlr + '= Translate(PfP' + zlr + ',' + 'Vector(' + pktL + ',' + obj + '))'
    );
    evcm('Midd' + zlr + ' = Midpoint(PfPr' + zlr + ',' + 'PfP' + zlr + ')'
    );
    evcm('Adjustor' + zlr + ' = Vector(Midd' + zlr + ',' + 'PfP' + zlr + ')'
    );
    evcm('Vector(Midd' + zlr + ',' + 'PfPr' + zlr + ')'
    );
    o = [
      'PfP' + zlr,
      'BlR' + zlr,
      'hght' + zlr,
      'BlL' + zlr,
      'PfPr' + zlr,
      'Midd' + zlr,
      'Adjustor' + zlr
    ];
    for (i = 0; i < o.length; i++)
    {
//      with (ggbApplet) {
        setLabelVisible(o[i], 0);
        setLineThicknes(o[i], 1);
        setFilling(o[i], 1);
//      }
    } // -  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    with (ggbApplet) {
      setVisible('PfP' + zlr, 1);
      setVisible('hght' + zlr, 1);
      setVisible('Midd' + zlr, 0);
      registerObjectClickListener('Adjuster' + zlr, 'BemaszerMxDstSwitcher');
      localStorage.setItem('laherBemaszerZaehler', parseInt(zlr) + 1);
      console.log('nachhher: ' + localStorage.getItem('laherBemaszerZaehler'));
    }
 } // - Target2nd ------------------------------------------------------------

    function
    BemaszerMxDstSwitcher() {
      with (ggbApplet) {
        setVisible('PfP' + zlr, !getVisible('PfP' + zlr));
        setVisible('hght' + zlr, !getVisible('hght' + zlr));
      }
    } // ------------------------------------------------

  }

Comments (4)

photo
1

Please explain clearly:


* what happens for you

* what you want to happen

photo
1

Hello Michael, thanks for looking into it

  • all labels that I think I had hidden show
  • the middpoint should not bee seen
  • all lines shoud be size 1
  • clicking the vector aiming left ( if you click A before B ) should switch the visibility of points "PfP." and "hght." ,
  • the dot stands for a number the should rise with every application


If you


here is the new version here https://www.geogebra.org/m/aprauhf2


    The point on the right arrowhead is moveable and doing it, the segments perpendicular to the vectors grow and the doublearrow beomes movable by the point of the leftside aiming one ( if you A was what you clicked 1st after Mßx ) .


    And is it right that there is no danger of address clashes in the "bei Mausklik" - and "Bei Update"- areas - except ggbApplet methods and data ? Somwhere a complete list?

    photo
    1

    and here the new code ( or is that iease to extract from the ggb file ?)

    ---------------------------------------------------------------------------------------------------------

    oh, yes, I am aware not only the Adjuster vectors need names so I can set their thickness and filling.


      const
      evcm = ggbApplet.evalCommand,
      RGL = ggbApplet.registerClickListener,
      uRGL = ggbApplet.unregisterClickListener
      ;
      uRGL('Target1st');
      uRGL('Target2nd');
    
      if (localStorage.getItem('laherBemaszerZaehler') == null)
      localStorage.setItem('laherBemaszerZaehler', 0)
      ;
      zlr = localStorage.getItem('laherBemaszerZaehler')
    
      RGL('Target1st');
      // -----------------------------------------------------------------
      function NoMszxBemaszung() {
        alert('Mßx zu bemaßen ist nicht vorgesehen;\n\
               Bitte vorhandenen Punkt klicken oder neuen setzen.'
        );
      } // ----------------------------------------------------------------
      function Target1st(obj) {
        uRGL('Target1st');
        if ('Mßx' == obj)
        { NoMszxBemaszung();
          return
        }
        localStorage.setItem('laherBemaszer1stObj', obj);
        RGL('Target2nd');
      } // -----------------------------------------------------------------
    
      function Target2nd(obj) {
        uRGL('Target2nd');
        if (((pktL = localStorage.getItem('laherBemaszer1stObj') // gewählter Punkt
        ) == obj)                                             // identisch mit dem
        || obj == 'Mßx')                                      // 1tem oder "Mßx"
        { if (!confirm('2ter Punkt muß verschieden von 1tem sein.\n\
                       Wenn Du nun nicht abbrichst ist der nächste\n\
                       geklickte Punkt ein "erster".')
        ){ RGL('Target1st'); return;
         }
        }
        zlr = localStorage.getItem('laherBemaszerZaehler');
    var PfP      ='PfP' + zlr,
        BlR      ='BlR' + zlr,
        hght     = 'hght' + zlr,
        BlL      ='BlL' + zlr,
        PfPr     ='PfPr' + zlr,
        Midd     ='Midd' + zlr,
        Adjustor ='Adjustor' + zlr,
               o = [ PfP,BlR,hght,BlL,PfPr,Midd,Adjustor
                  ];
       zlr = localStorage.getItem('laherBemaszerZaehler')
    
      RGL('Target1st');
        evcm( PfP + '= Point(PerpendicularLine('+ pktL + ',' + 'Segment('+ pktL + ',' + obj + ') ) )'
        );
        evcm( hght +'= Point( PerpendicularLine(' +obj +','+ 'Segment('+pktL+','+obj+ ') ) )'
        );
        evcm( BlR +'= Segment('+obj+','+hght+')'
        );
        evcm( BlL + '= Translate(' + BlR + ',' + 'Vector(' + obj + ',' + pktL + '))'
        );
        evcm( PfPr+ '= Translate('+ PfP + ',' + 'Vector(' + pktL + ',' + obj + '))'
        );
        evcm( Midd +'= Midpoint('+ PfPr + ',' + PfP + ')'
        );
        evcm( Adjustor + ' = Vector('+ Midd + ',' + PfP + ')'
        );
        evcm('Vector(' + Midd + ',' + PfPr + ')'
        );
        for (i = 0; i < o.length; i++)
        {
         with (ggbApplet) {
            setLabelVisible(o[i], 0);
            setLineThicknes(o[i], 1);
            setFilling(o[i], 1);
          }
        } // -f o r - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        with (ggbApplet) {
          setVisible( PfP, 1);
          setVisible( hght, 1);
          setVisible( Midd , 0);
          registerObjectClickListener( Adjuster + ', BemaszerMxDstSwitcher');
          localStorage.setItem('laherBemaszerZaehler', parseInt(zlr) + 1);
          console.log('nachhher: ' + localStorage.getItem('laherBemaszerZaehler'));
        } // ----------------------------------------------------------------------
        function
        BemaszerMxDstSwitcher() { // geschachtelt in Target2nd um var's
          with (ggbApplet) {      //              nutzen zu können
            setVisible( PfP, !getVisible( PfP ));
            setVisible( hght,!getVisible( hght));
          }
        }
     } // - Target2nd ------------------------------------------------------------
     // ------------------------------------------------
    
      }
    

    photo
    2

    just the last intended reaction does not come yet:


    clicking on the left half of te double arrow is expected to hide / show the points PfP26 and hght26 . ( the one on the left arrowhead and the other below the right arrowhead ) .

    The hide /show should be enabled by code line 115 and don by lines 124,125


    Point PfP.. and hght.. ( the dots symbolise numbers )) can be drawn to adjust the position of the doublearrow and the length and direction of the segments resting in points C amd D .

    /* Egal,
     * wie sich das Objekt nennt, dessen "Bei Mausklick"-Tab diesen Code speichert,
     * es
     * kann nichts schlimmeres passieren
     * als
     * daß ein paar versehentlich gezeichnete Linien wieder gelöscht werden müssen.
     * Daher
     * sind die Funktion "besserNie" und ihre Aufruf auskommentiert.
     */
    {
      const
      evcm = ggbApplet.evalCommand,
      RGL = ggbApplet.registerClickListener,
      uRGL = ggbApplet.unregisterClickListener
      ;
      uRGL('Target1st');
      uRGL('Target2nd');
      if (localStorage.getItem('laherBemaszerEinAus') == null)
      {
        localStorage.setItem('laherBemaszerEinAus', 0);
      }
      if (confirm('OK-Klick SCHALTET Bemaßen EIN;'))
      {
        localStorage.setItem('laherBemaszerEinAus', 1);
        RGL('Target1st');
      } // -----------------------------------------------------------------
    
    //function besserNie(numm) {
    //  alert('sollte eigenlich nicht vorkommen;'
    //  + num + 'Klick');
    //} // -----------------------------------------------------------------
    //
      function Target1st(obj) {
    //  if ('Mßx' == obj) {
    //    besserNie('1.');
    //    return;
    //  }
        localStorage.setItem('laherBemaszer1stObj', obj);
        uRGL('Target1st')
        RGL('Target2nd');
      } // -----------------------------------------------------------------
    
      function Target2nd(obj) {
    //  if ('Mßx' == obj) {
    //    besserNie('2.');
    //    return;
    //  }
        var pktL = localStorage.getItem('laherBemaszer1stObj');
        if (obj == pktL) {
          if (confirm('2ter Punkt muß verschieden von 1tem sein.\n\
                       Wenn Du nun OK klickst ist der nächste\n\
                       geklickte Punkt ein "erster".'
          )
          )
          {
            RGL('Target1st');
            uRGL('Target2nd');
            return;
          }
          return;
        }
        uRGL('Target2nd');
        var zlr = localStorage.getItem('laherBemaszerZaehler'),
        PfP = 'PfP' + zlr,
        BlR = 'BlR' + zlr,
        hght = 'hght' + zlr,
        BlL = 'BlL' + zlr,
        PfPr = 'PfPr' + zlr,
        Midd = 'Midd' + zlr,
        Adjustor = 'Adjustor' + zlr,
        theother = 'theother' + zlr
        ;
        evcm(PfP + '= Point(PerpendicularLine(' + pktL + ',' + 'Segment(' + pktL + ',' + obj + ') ) )'
        );
        evcm(hght + '= Point( PerpendicularLine(' + obj + ',' + 'Segment(' + pktL + ',' + obj + ') ) )'
        );
        evcm(BlR + '= Segment(' + obj + ',' + hght + ')'
        );
        evcm(BlL + '= Translate(' + BlR + ',' + 'Vector(' + obj + ',' + pktL + '))'
        );
        ggbApplet.setLabelVisible(hght + '\'', 0);
        ggbApplet.setLabelVisible(obj + '\'', 0);
        evcm(PfPr + '= Translate(' + PfP + ',' + 'Vector(' + pktL + ',' + obj + '))'
        );
        evcm(Midd + '= Midpoint(' + PfPr + ',' + PfP + ')'
        );
        ggbApplet.setVisible(Midd, 0);
        evcm(Adjustor + ' = Vector(' + Midd + ',' + PfP + ')'
        );
        evcm(theother + ' = Vector(' + Midd + ',' + PfPr + ')'
        );
        [
          PfP,
          hght,
          BlR,
          BlL,
          PfPr,
          Adjustor,
          theother
        ].forEach(function (pnt) {
          ggbApplet.setLabelVisible(pnt, 0);
        }
        );
        ggbApplet.setVisible(PfPr, 0)
        ggbApplet.setVisible(hght + '\'', 0);
        [
          BlL,
          Adjustor,
          theother,
          BlR
        ].forEach(function (l) {
          ggbApplet.setLineThickness(l, 1);
          ggbApplet.setFilling(l, 1);
        });
        ggbApplet.registerObjectClickListener(Adjustor, 'BemaszerMxDstSwitcher');
    console.log( Adjustor )
        localStorage.setItem('laherBemaszerZaehler', parseInt(zlr) + 1);
        console.log('nachhher: ' + localStorage.getItem('laherBemaszerZaehler'));
        // ----------------------------------------------------------------------
        function
        BemaszerMxDstSwitcher() { // geschachtelt in Target2nd um var's
                                  //              nutzen zu können
    
          ggbApplet.setVisible(PfP, !ggbApplet.getVisible(PfP));
          ggbApplet.setVisible(hght,!ggbApplet.getVisible(hght));
        }
      } // - Target2nd ------------------------------------------------------------
    
    } // const
    

    © 2021 International GeoGebra Institute