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

    Auto close UI.messagebox (Bug or feature?)

    Scheduled Pinned Locked Moved Developers' Forum
    8 Posts 4 Posters 1.4k 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.
    • D Offline
      dezmo
      last edited by

      Hi All,
      I did not find "official" method to automatically close messagebox. However when I tried to find some similar accidentally i find out this:
      (Paste it to your console.)

      wd = UI;;WebDialog.new("Dialog", true, "W1", 800,800,100,100,true)
      wd.set_html("This window will close automaticaly after 5 sec...")
      id = UI.start_timer(5, false) { wd.close;UI.beep }
      wd.show
      UI.messagebox('Do not click OK!...SketchUp will close this too')
      

      Btw: if you size the webdialog smaller than messagebox it is looks like you ara using only messagebox. (Since SU will put the messagebox same place as wd.)

      Is that a known feature or bug?

      Man can do everything. Only a matter of time and money.

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

        @dezmo said:

        Is that a known feature or bug?

        That is a definite bug. No programmer in their right mind would purposely set that up to work that way.

        I'm not here much anymore.

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

          That's very strange... not sure what is going on there. Bug for sure.

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

          1 Reply Last reply Reply Quote 0
          • D Offline
            driven
            last edited by

            BTW: UI.messagebox must be clicked to close on a mac, as expected...

            john

            learn from the mistakes of others, you may not live long enough to make them all yourself...

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

              On Windows, the native messagebox window objects can be set to autoclose, as the function has a timeout argument. But the SU API never leveraged this feature.

              Trying to use WScript shell object's messagebox interface from SketchUp Ruby to have auto-close message box windows is a failure. What happens is the windows are on top of the Z order, but non-modal. Ie the user can use the SketchUp interface whilst the messagebox remains open. This shouldn't really occur.

              Wrapping the code in a UI.start_timer just makes things weirder and weirder. I did get them to auto-close but, the amount of time they are open is pseudo-random (depending on what happens in the background.) IE, if I tell it to stay open 3 seconds, it will be open somewhere between 5..10 seconds.

              I gave up after a few days of wasted effort.

              I'm not here much anymore.

              1 Reply Last reply Reply Quote 0
              • D Offline
                dezmo
                last edited by

                I hope it will be corrected sometime..and real autoclose (or close from code) will implemented for messagebox.

                Man can do everything. Only a matter of time and money.

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

                  @dezmo said:

                  I hope it will be corrected sometime..and real autoclose (or close from code) will implemented for messagebox.

                  What would the use case for that be?

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

                  1 Reply Last reply Reply Quote 0
                  • D Offline
                    dezmo
                    last edited by

                    @thomthom said:

                    What would the use case for that be?

                    If you know in advance that there will be long operation, you can prepare a message box which will come after e.g. 5-10 min. " It seems to much time to process, do you want to abort or go ahead?"
                    The UI:messagebox is suspending the operation and the code is continuing if it is closed. (At least in windows...)
                    But if the user is not responding for e.g. 30-60sec the message box will close automaticly and the code is continuing to process.

                    You can't use webdialog, because in long operation SU (including WD) is not responding at all.

                    For sure there is other workaround, or possible to do your code on other way, but this could be an "easy" solution...

                    (I'm just an amateur engineer, not a programmer ... πŸ˜‰ )

                    Man can do everything. Only a matter of time and money.

                    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