π‘ LightUp 7.1 | SketchUp's only real-time renderer that uses object-based rendering
Download Trial
How to avoid multiple instances of WebDialog?
-
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. -
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.
-
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
-
@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
Advertisement