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

    Allow to start a plugin just once

    Scheduled Pinned Locked Moved Developers' Forum
    4 Posts 3 Posters 78 Views 3 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
      niccah
      last edited by

      I'm wondering, that I can't find a nice solution, to allow to start a plugin just once.

      So, with the help of my plugin, I start a WebDialog... How I can ask, if there is the same WebDialog already opened?

      I think, this should be very easy, but, sorry...

      I tried:

      if (!defined? dlg) dlg = UI::WebDialog.... else dlg.bring_to_front

      But with this version, I am able to start several WebDialogs...

      Thanks for your help!

      1 Reply Last reply Reply Quote 0
      • TIGT Online
        TIG Moderator
        last edited by

        Assuming your code is wrapped inside a method inside a module... then referring to the web-dialog like this will use the same object IF it already exists, and if it doesn't it makes a new one...
        @dlg = UI::WebDialog.new(...) unless @dlg
        Then later use @dlg to change its url, show it etc, and set/reset all other options available etc...

        TIG

        1 Reply Last reply Reply Quote 0
        • N Offline
          niccah
          last edited by

          Sometimes, it is so easy! 😄

          Thanks TIG!!

          1 Reply Last reply Reply Quote 0
          • Dan RathbunD Offline
            Dan Rathbun
            last edited by

            @tig said:

            Then later use @dlg to change its url, show it etc, and set/reset all other options available etc...

            This is important!

            The dialog instance is not destroyed when you close it. You can re-open it again.
            And if you had data from the dialog, stored in Ruby vars, you can reset them back into the dialog's Javascript vars, after it reopens.

            I'm not here much anymore.

            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