• Login
sketchucation logo sketchucation
  • Login
⚠️ Libfredo 15.4b | Minor release with bugfixes and improvements Update

Send string value to Webdialog

Scheduled Pinned Locked Moved Developers' Forum
7 Posts 4 Posters 327 Views 4 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 26 Feb 2009, 11:46

    This is how it can be done (besides JSON)

    Example.

    In ruby

    name="blablabla"
    command = "_showdata('taskname', '#{name}')"
    dialog.execute_script(command)
    

    In webdialog

    function _showdata(id,value) {
    	var element = document.getElementById(id);
    	element.value = value; 
      	}
    

    The only problem i have is:
    Ruby continues interpreting script without waiting.
    For example: if the dialog is not yet open, you test on that and first open the dialog, the value will not be shown in the dialog. App. the ruby script just continues without waiting tille the dialog is open. Now if i place a UI.messagebox just before the command line all goes well.

    Is there any way to hold the ruby script so it only continues if the dialog script is executed? Or is there another way to do this?

    1 Reply Last reply Reply Quote 0
    • T Offline
      thomthom
      last edited by 27 Feb 2009, 08:13

      I suppose you could make up an array of commands that would stack up if the webdialog isn't open. Then, when it does loop through and send them.

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

      1 Reply Last reply Reply Quote 0
      • J Offline
        Jim
        last edited by 27 Feb 2009, 11:14

        Maybe use the show{} method to defer execution?

        
        dlg = WebDilaog.new(...)
        #... 
        dlg.show {
          # your code here
        }
        
        
        

        Hi

        1 Reply Last reply Reply Quote 0
        • C Offline
          chrisglasier
          last edited by 27 Feb 2009, 13:07

          If you are going to open a web dialog I would recommend you always control the action from the dialog's javascript - onload call ruby callback > receive ruby execute script.

          Chris

          With TBA interfaces we can analyse what is to be achieved so that IT can help with automation to achieve it.

          1 Reply Last reply Reply Quote 0
          • P Offline
            Pout
            last edited by 2 Mar 2009, 09:23

            Hey Chris,

            Do you have an example for me?
            Thanks!

            1 Reply Last reply Reply Quote 0
            • C Offline
              chrisglasier
              last edited by 2 Mar 2009, 09:31

              Open transformations.zip from here .

              Let me know if you have any problems.

              Chris

              edit: in my last post there

              With TBA interfaces we can analyse what is to be achieved so that IT can help with automation to achieve it.

              1 Reply Last reply Reply Quote 0
              • P Offline
                Pout
                last edited by 2 Mar 2009, 10:51

                ok i'll look into it 😄
                Thanks!

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

                Advertisement