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

    Webdialogs on Mac.

    Scheduled Pinned Locked Moved Developers' Forum
    6 Posts 4 Posters 2.2k 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.
    • C Offline
      CPhillips
      last edited by

      I am having some problems getting a Webdialog to work on Mac. The problem is that execute_script()function doesn't seem to do anything on Mac. The following code is adapted from the documentation. It works on Win but doesn't do anything on Mac.

      
              $testdialog=UI;;WebDialog.new("Test", true,"testkey", 250, 600, 600, 250, true)
              html='<HTML><HEAD></HEAD><body><div id="testdiv"></div></body></HTML>'
              $testdialog.set_html(html)
              $testdialog.show {
                  java='document.getElementById("testdiv").innerHTML="Hello World"'
                  $testdialog.execute_script(java) 
              }
      
      

      Am I doing something wrong? Can anyone confirm that execute_script works on Mac?

      Thanks
      Chris

      1 Reply Last reply Reply Quote 0
      • T Offline
        todd burch
        last edited by

        execute_script works on a Mac.

        Before you do that, try adding a semi colon to the end of your javascript clause. If that won't do it, put your getElementById stuff in a function, and call the function via execute_script, passing whatever you want to set the innerHTML to as the parm.

        execute_script works better than set_html. Use set_file on a Mac and it'll work every time.

        Todd

        1 Reply Last reply Reply Quote 0
        • C Offline
          CPhillips
          last edited by

          @unknownuser said:

          execute_script works on a Mac.

          Before you do that, try adding a semi colon to the end of your javascript clause. If that won't do it, put your getElementById stuff in a function, and call the function via execute_script, passing whatever you want to set the innerHTML to as the parm.

          execute_script works better than set_html. Use set_file on a Mac and it'll work every time.

          Todd

          I have narrowed it down a bit. I can call javascript functions that are already defined in a html but I cant get access to "document" or "window" directly. I can and will write wrappers if I need to. But it would be a pain.

          I tried adding a semicolon to the line above and it made no difference. In fact semicolons seem to cause problems in certain cases on Mac.

          execute_script("somefunc('hello');")

          Calls the javascript func with the string: "hello);" on Mac. But if I leave the semicolon off it seems to work as intended.

          In my real app I am using set_file. The example was a stripped down case.

          Here is an even simpler case:

          
          dialog.execute_script("window.alert('hello')")
          
          

          That works on Windows shouldn't it work on Mac?

          1 Reply Last reply Reply Quote 0
          • T Offline
            todd burch
            last edited by

            Yes, it should work on a Mac. I lost track of how many webdialog bugs I've reported to Google, that they have also acknowledged.

            1 Reply Last reply Reply Quote 0
            • E Offline
              enjahova
              last edited by

              I ran into a problem on OS X, Sketchup version 7 where the execute_script worked, but the WebDialog wouldn't refresh.
              I noticed an alert(); would refresh it, but that would be annoying so this was my workaround:
              in your javascript callback function put:
              window.location.href = "#someanchor"

              which will reload your webdialog on the original page, with all the .innerHTML's executed!

              1 Reply Last reply Reply Quote 0
              • scottliningerS Offline
                scottlininger
                last edited by

                Bugs noted. Thanks, guys!

                We fixed some WebDialog mac bugs with 7.0, but there's obviously still work to be done.

                Cheers,

                • Scott Lininger
                  SketchUp Software Engineer
                  Have you visited the Ruby API Docs?
                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