no reaction from registered listener why ?

FriedrichLaher shared this question 1 year ago
Needs Answer

againListener


lines 46 and 51; because 46 does not work lines 48,49 to demonstrate what's intended


but of course, then, after click on Mßz click on any 2 Points are the use of it.

function lvl0(){ // localStorage.clear()  ; // entfällt wenn fertig; hier im forum vorsichtshalber nichts löschen

  c = confirm;
  var ap   = ggbApplet; var lsi = "laherBemaßerZähler";
  var ruf  = 1;
    var
    zlr = localStorage.getItem( lsi );
    zlr
    = ( zlr != null ) ? parseInt(zlr) + 1 : 0;

    localStorage.setItem(lsi,zlr);

    var pktL,pktR, mx = "mx" + zlr, dst = "dst" + zlr
    ;
    const  K  = ",";
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  function target(obj){ // aufgerufen, "linker Endpunkt"
                   //         der zu bemaßenden Strecke
  c("target("+obj+")");
          if (obj == "Mßx")
          { ruf = 1; alert("Bemaßung abgebrochen ");
                  ap.unregisterClickListener("target");
          }
          if ( ruf ) {pktL = obj; ruf = 0; return;} // 1ter, "linker"
               else  {pktR = obj; ruf = 1;          // 2ter, r.ter Punkt
                         ap.unregisterClickListener("target");
                     };
  ec = ap.evalCommand;

  ec(mx+" = Point(PerpendicularLine("+pktL+K+"Segment("+pktL+K+pktR+") ) )"
  );
  ap.setVisible(mx,0);
  ec("blA = Segment(" +pktL+K+mx+")"
  );
  ec(dst+" = Point(blA)"
  );
  ec("blB  = Translate(blA, Vector(" +pktL+K+pktR+") )"
  );
  ec("dstB = Translate("+dst+K+"Vector(" +pktL+K+pktR+") )"
  );
  ap.setVisible("dstB",0);
  ec("Vector(Midpoint("+dst+K+"dstB),dstB)"
  );
  ec("adjuster"+zlr+" = Vector(Midpoint("+dst+K+"dstB),"+dst+")"
  );
  } //  target ---------------------------------------------
  ggbApplet.registerClickListener("target");
  c("registered")
  target("A"); // nur, um übriges testen zu können bis target
  target("B");  // auch wirklich als clickListener arbeitet
// ------------------------------------------------------------
  ap.registerObjectClickListener("bemaszerMxDstSwitcher")
  function
    bemaszerMxDstSwitcher(){
              ap.setVisible( mx,!ap.getVisible( mx) );
              ap.setVisible(dst,!ap.getVisible(dst) );
    } // -------------------------------------------------------
} // lvl0
lvl0();

Comments (2)

photo
1

Please explain:

  • expected behaviour
  • what happens for you

photo
1

Expected behaviour:


after clicking point Mßx

the clicklistener target

shoul process the next 2 clicks


drawing the following figure

1d112ca6d75bffbef08356725b683380and

before deaktivating himself

aktivate bemaszerMxDstSwitche

as

ObjectClickListener for vector

adjuster.. that toggles the

visibility of points mx.. and dst..

which allow when visible, adjust the

length of theshort segments perpendicular to the

vectors and the placing of the vectors .


( .. stands for the integer zlr kept

in localStorage

)

WHAT HAPPENS FOR ME:


the code is stored as "on click code",

but except for the outputs of the confirms nothing visible

happens if the direct calls of function target are

comennted out

photo
© 2020 International GeoGebra Institute