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

    UI.inputbox with Web Dialog

    Scheduled Pinned Locked Moved Developers' Forum
    5 Posts 4 Posters 1.1k 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.
    • medeekM Offline
      medeek
      last edited by

      I found the UI.inputbox too limiting so I've decided to implement a web dialog with some html drop downs for selecting certain options. The problem I am having is that I have an inputbox that appears directly after the web dialog in the flow of my code. Somehow I need to pause the program flow until I get the correct response back from the web dialog and then proceed to the next step which is the input box.

      I was thinking of using a while statement but this seems a little clunky to me. Just wondering what the pros would use in this type of situation.

      I agree multiple inputs popping up one after the other is probably not the slickest user interface but that is what I have for now. At some point I will probably replace all the inputbox entries with web dialogs but for now I'm going to try to make them work together.

      Nathaniel P. Wilkerson PE
      Medeek Engineering Inc
      design.medeek.com

      1 Reply Last reply Reply Quote 0
      • medeekM Offline
        medeek
        last edited by

        Using the modal method would seem to be the solution (WebDialog.show_modal) but this would be a problem for Mac users since it is not truly modal. Has anyone encountered this sort of thing before and is there a good work around?

        Nathaniel P. Wilkerson PE
        Medeek Engineering Inc
        design.medeek.com

        1 Reply Last reply Reply Quote 0
        • M Offline
          MSP_Greg
          last edited by

          Nathan,

          Simply put, the best solution is to have your program flow based on callbacks from the WebDialog. This often creates problems for people, as the UI.inputbox is blocking. So the code is something like this:

          
          def start_method
            # some code to initialize and load inputbox
            UI.inputbox(*args)
            # more code for operation
          end
          
          

          The above is very linear and not easily changed to an event driven style. Better to start with something like:

          
          def start_method
            # some code to initialize and load inputbox
            UI.inputbox(*args1)
            ui_input_done(args2)
          end
          
          def ui_input_done(*args2)
            # more code for operation
          end
          

          Then, if you decide a WebDialog is needed:

          
          def start_method
            @dlg = UI;;WebDialog.new()
            # load @dlg html, etc
            @dlg.add_action_callback { |dlg, ret|
              # gather data from dlg
              ui_input_done(*args2)
            }
            @dlg.show()
          end
          
          

          To really give the user a good UI experience, one has to write javascript for the WebDialog.

          Greg

          [anchor="1" goto="http://msp-greg.github.io/su_info/index.html":17i7mw7a]GitHub.io SketchUp Misc Docs[/anchor:17i7mw7a]

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

            For general info about WebDialogs:
            https://github.com/thomthom/sketchup-webdialogs-the-lost-manual

            For a Ruby wrapper over WebDialog:
            https://github.com/thomthom/SKUI

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

            1 Reply Last reply Reply Quote 0
            • hsmyersH Offline
              hsmyers
              last edited by

              @thomthom said:

              Link Preview Image
              GitHub - thomthom/SKUI: Ruby wrapper of classes that maps to GUI controls in SketchUp's UI::WebDialogs

              Ruby wrapper of classes that maps to GUI controls in SketchUp's UI::WebDialogs - thomthom/SKUI

              favicon

              GitHub (github.com)

              Could you add version to README.md? Pretty please with a cookie? ☀

              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