sketchucation logo sketchucation
    • Login
    Oops, your profile's looking a bit empty! To help us tailor your experience, please fill in key details like your SketchUp version, skill level, operating system, and more. Update and save your info on your profile page today!
    πŸ«› Lightbeans Update | Metallic and Roughness auto-applied in SketchUp 2025+ Download

    How to avoid multiple instances of WebDialog?

    Scheduled Pinned Locked Moved Developers' Forum
    4 Posts 4 Posters 208 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.
    • N Offline
      NewOne
      last edited by

      Is there a way to avoid multiple WebDialog instances to open? I'm making some tests/learning how to handle JS and webdialogs and I observed that each time I load my webdialog.rb file, it opens a new window without affecting previous ones.
      I'd like to force somehow just one window, or to close the old one when the new one is created.
      Thanks.

      1 Reply Last reply Reply Quote 0
      • R Offline
        remus
        last edited by

        bit of a guess as i havent done anything with web dialogs before, but could you try and talk to the webdialog before you open a new one? that way you could test if ones already open then open a new one if necessary.

        http://remusrendering.wordpress.com/

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

          
          module MyDialog
          
          # Use a module variable to store one reference to your dialog
          @dialog = UI;;WebDialog.new("Show Google.com", true,
             "ShowGoogleDotCom", 739, 641, 150, 150, true);
          @dialog.set_url "http://www.google.com"
          
          def self.show_dialog
            # Now you can use that variable to check if it's already visible or not
            if @dialog.visible?
              @dialog.show
            else
              @dialog.bring_to_front
            end
          end
          
          end
          
          

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

          1 Reply Last reply Reply Quote 0
          • chrisglasierC Offline
            chrisglasier
            last edited by

            @thomthom said:

            
            > module MyDialog
            > 
            > # Use a module variable to store one reference to your dialog
            > @dialog = UI;;WebDialog.new("Show Google.com", true,
            >    "ShowGoogleDotCom", 739, 641, 150, 150, true);
            > @dialog.set_url "http://www.google.com"
            > 
            > def self.show_dialog
            >   # Now you can use that variable to check if it's already visible or not
            >   if @dialog.visible?
            >     @dialog.show
            >   else
            >     @dialog.bring_to_front
            >   end
            > end
            > 
            > end
            > 
            

            Very good. I know not for me but thanks

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

            Advertisement