• Login
sketchucation logo sketchucation
  • Login
πŸ€‘ SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

WebDialog (Mac) - style.visibility in SU6

Scheduled Pinned Locked Moved Developers' Forum
8 Posts 2 Posters 666 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.
  • T Offline
    tomasz
    last edited by 17 Sept 2010, 15:42

    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
    • T Offline
      thomthom
      last edited by 18 Sept 2010, 11:42

      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 18 Sept 2010, 14:21

        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
        • T Offline
          thomthom
          last edited by 18 Sept 2010, 14:50

          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
          • T Offline
            thomthom
            last edited by 18 Sept 2010, 14:50

            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 18 Sept 2010, 19:16

              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
              • T Offline
                thomthom
                last edited by 19 Sept 2010, 08:37

                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 19 Sept 2010, 15:23

                  @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
                  1 / 1
                  • First post
                    4/8
                    Last post
                  Buy SketchPlus
                  Buy SUbD
                  Buy WrapR
                  Buy eBook
                  Buy Modelur
                  Buy Vertex Tools
                  Buy SketchCuisine
                  Buy FormFonts

                  Advertisement