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

    Messagebox of doom!

    Scheduled Pinned Locked Moved Developers' Forum
    5 Posts 2 Posters 452 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.
    • thomthomT Offline
      thomthom
      last edited by

      UI.start_timer( 0, false ) { UI.messagebox('Hello World') }

      That, makes a long loop of messageboxes appear. I have to press Return down to stop them. And then the Ruby Console history is filled with empty lines...

      What gives?

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

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

        Just to make it a more sane - try with one second.

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

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

          This works as I would like my original code to behave:
          t=UI.start_timer( 1, false ) { UI.stop_timer(t); UI.messagebox('Hello World'); };

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

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

            @thomthom said:

            This works as I would like my original code to behave:
            t=UI.start_timer( 1, false ) { UI.stop_timer(t); UI.messagebox('Hello World'); };

            You might expect that UI.start_timer( 0, false ) { UI.messagebox('Hello World') } would kick in after '0'seconds ONCE and put up the messagebox BUT if you don't close the messagebox within a VERY short time it puts up another one!!!
            t=UI.start_timer( 1, false ) { 1.times{UI.stop_timer(t); UI.messagebox('Hello World')}} works as you only make one instance ?

            TIG

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

              @tig said:

              t=UI.start_timer( 1, false ) { 1.times{UI.stop_timer(t); UI.messagebox('Hello World')}} works as you only make one instance ?

              What I think happens is:

              SketchUp stops non-repeating timers ( with the repeat flag to false ) after it processes the block given to UI.start_timer. Because the messagebox is modal it halts normal execution, but the timer stills runs because it hasn't been stopped yet. My workaround is to manually stop it before the messagebox is displayed.

              I'd expect to see the same behaviour from modal webdialogs.

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

              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