sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    Webdialog stops working after action_calback

    Scheduled Pinned Locked Moved Developers' Forum
    3 Posts 2 Posters 190 Views 2 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • P Offline
      Pout
      last edited by

      Script structure:

      User clicks a button
      This sets an selection observer and opens a webdialog1
      Each time the user clicks another SU entity the content of the webdialog1 is updated
      In webdialog1 are clcikable hyperlinks pointing to a javascript that executes an action callback towards the script again.

      In that action callback, at ruby side a value in another webdialog is updated.
      This all goes well.

      But from then on (so when the hyperlink is clicked in webdialog1 and the value is updated in webdialog2) the content of webdialog1 does not change anymore when clicking another SU entity.

      Somewhere along the line something falls apart. Any ideas?
      If wanted i can post a movie of the action.

      Thx,
      Pout

      1 Reply Last reply Reply Quote 0
      • thomthomT Offline
        thomthom
        last edited by

        Hard to tell without some code. You got a bare-bone case?

        Sounds like you're missing the references somewhere...

        Thomas Thomassen — SketchUp Monkey & Coding addict
        List of my plugins and link to the CookieWare fund

        1 Reply Last reply Reply Quote 0
        • P Offline
          Pout
          last edited by

          here it goes (it's still a dev)

          1.webdialog 1 opened with:

          $xdinfowindowke=UI;;WebDialog.new("xDInfo", true,"xDInfo",290,300,0,0,true)
          fn= $html_folder+"/xD_infowindow.html"
          $xdinfowindowke.set_file fn
          $xdinfowindowke.set_size(290,300)
          $xdinfowindowke.show {}
          

          2.populated from ruby with

          //activated each time another SU entity is clicked
          command = "_sendinfo('#{$sendobjectid}','#{$sendlist}')"
          $xdinfowindowke.execute_script(command)
          

          3.javascript in webdialog 1

          function _sendinfo(theobjectid, theinfo){
          //fill in the rows
          attr=theinfo.split("|||");
          for (i=0;i<attr.length;i++){
          	splitted=attr[i].split("$$$")
          	var oRow = oBody.insertRow(-1);
          	//insert the first cell
          	var oCell = oRow.insertCell(-1);
          	oCell.className="attrnames";
          	oCell.innerHTML = splitted[0]+";";
          	//insert the second cell
          	var oCell = oRow.insertCell(-1);
          	oCell.className="attrnames";
          	//if it is the objectname, make clickable
          	if (i==0){
          		oCell.innerHTML = "<a href='javascript&#058;_show4Dobject("+theobjectid+")'>"+splitted[1]+"</a>";
          	}
          	else {
          		//if the string contains ^ it means it is a link. split up
          		if(splitted[1].indexOf("^") != -1){
          			waw=splitted[1].split("^");
          			oCell.innerHTML='<a href="'+waw[1]+'" target=_blank">'+waw[0]+'</a>';
          		}
          		else {
          			oCell.innerHTML = splitted[1];
          		}
          	}
          }
          	//add the end attach a last row
          	var oRow = oBody.insertRow(-1);
          	var oCell = oRow.insertCell(-1);
          	oCell.height="1px";
          	oCell.colSpan="2";
          	oCell.className="split";
          }
          
          1. This makes some html links in webdialog1 with this code:
          <a href='javascript&#058;_show4Dobject([i]id[/i])'>"[i]name[/i]"</a>
          

          handled by this code in webdialog1:

          function _show4Dobject(objectid){
          query = 'skp;_show4dobjects@'+objectid;
          window.location.href = query;
          }
          
          1. Now back in SU this is handled by:
          $xdinfowindowke.add_action_callback("_show4dobjects") {|$xdinfowindowke,p|
          	#check if the xdwindow is open--> [b]this is another window[/b]
          	if $xdwindow
          		visible=$xdwindow.visible?
          		if visible==true
          			command = "_xdhighlight('#{p}')"
          			$xdwindow.execute_script(command)
          		else
          			UI.messagebox('Open the 4D Objects window to highlight')
          		end
          	else
          		UI.messagebox('Open the 4D Objects window to highlight')
          	end
          		
          }
          

          Basically this all goes fine. When the html link is clicked in webdialog1, something happens in webdialog2
          But from there on, when i click another SU entity the content of webdialog1 is not updated anymore.
          Hope the information here helps.

          Thx!

          1 Reply Last reply Reply Quote 0
          • 1 / 1
          • First post
            Last post
          Buy SketchPlus
          Buy SUbD
          Buy WrapR
          Buy eBook
          Buy Modelur
          Buy Vertex Tools
          Buy SketchCuisine
          Buy FormFonts

          Advertisement