UI.inputbox with Web Dialog
-
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.
-
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?
-
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]
-
For general info about WebDialogs:
https://github.com/thomthom/sketchup-webdialogs-the-lost-manualFor a Ruby wrapper over WebDialog:
https://github.com/thomthom/SKUI -
Advertisement