sketchucation logo sketchucation
    • Login
    ℹ️ GoFundMe | Our friend Gus Robatto needs some help in a challenging time Learn More

    WebDialog (Mac) - style.visibility in SU6

    Scheduled Pinned Locked Moved Developers' Forum
    8 Posts 2 Posters 666 Views
    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.
    • T Offline
      tomasz
      last edited by

      I have been testing a WebDialog on Mac that uses a visibility of an object

      getElemendById(id).style.visibility='hidden';
      

      For some reason SU6 fails to set the visibility. SU7 & SU8 are doing just fine.

      Have anyone experienced similar problem? Is there an easy solution?

      Author of [Thea Render for SketchUp](http://www.thearender.com/sketchup)

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

        I'm guessing you are sending getElemendById(id).style.visibility='hidden'; to execute_script? Then I think there are character escaping issues if I remember correctly - and it might be different from Windows to OSX.

        If this is not sent to execute_script, - then I'm puzzled.

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

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

          I use following function in JS:

          	function ShowObject(id, flag)
          	{
          	   var elem=document.getElementById(id);
          	   if(elem)
          	      elem.style.visibility=flag?'visible';'hidden';
          	}
          

          and I send wd.execute_script("ShowObject('something', 0);")
          For some reason in works on MAC in SU7&8, doesn't hide a thing in SU6(also MAC).

          If I understand correctly SU uses Safari in all versions of SU on Mac. Where can the difference come from? I have no clue.

          Author of [Thea Render for SketchUp](http://www.thearender.com/sketchup)

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

            Yea - if you test on the same machine the webdialog behaviour be the same between SU versions - which makes me think this is a ruby API bug with execute_script.

            From the Lost Manual: http://forums.sketchucation.com/viewtopic.php?f=180&t=23445

            @unknownuser said:

            OSX .execute_script and quotes
            There was some issues with .execute_script and quotes in Sketchup prior to 7.0 on OSX. http://forums.sketchucation.com/viewtopic.php?f=180&t=8316#p49259

            Though that suggested an OSX only problem. You are saying it's on Windows as well?

            CPhillips suggested semi-colons could be an issue: http://forums.sketchucation.com/viewtopic.php?f=180&t=8316#p49259

            @cphillips said:

            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.

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

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

              In your ShowObject(id, flag) function, have you inspected the data it receives?

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

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

                Thanks Thomas for help.
                I have checked the JS function and I have found that on SU6 the 'flag' which is either 0 or 1 was not recognized by the following code:

                elem.style.visibility=flag?'visible';'hidden';
                

                I decided to send 'visible' or 'hidden' instead of numbers. Now JS works fine.

                I think that JS expected integers and couldn't convert strings comming from SU6?

                Author of [Thea Render for SketchUp](http://www.thearender.com/sketchup)

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

                  with your original code, did you try a typeof test of the flag? just to see what it came across as?
                  did you try without semi-colon?

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

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

                    @thomthom said:

                    with your original code, did you try a typeof test of the flag? just to see what it came across as?

                    I am not JS expert, so I didn't even know that 'typeof' exists 😄. Will check the old code.

                    @thomthom said:

                    did you try without semi-colon?

                    Yep. I didn't help.

                    Author of [Thea Render for SketchUp](http://www.thearender.com/sketchup)

                    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