Tool <> WebDialog <> Observers relationship
-
def onCancel(reason,view) @web_dialog.close endDo you need to close the webdialog here? It does not stop the Tool.
If the tool is a line tool for instance, and the user starts to draw a line:
Clicks once to set start point - then the tool enters a state where it expects the user to pick another. but if the user hit Escape this event is triggered withreason == 0- and the tool should then reset itself. But the tool itself is not killed. -
@dlg.set_on_close { puts "Set on close fired." Sketchup.active_model.active_view.remove_observer ProperTool::get_view_observer Sketchup.active_model.select_tool(nil) }Regarding
Sketchup.active_model.select_tool(nil)- that will activate SU's Select tool. I'd recommend that you instead useSketchup.active_model.tools'spush_toolandpop_toolso that when you deactivate your own tool it return to the previously selected tool (which might very likely not be the Select tool) -
@thomthom said:
You're missing a
puts.
@thomthom said:
> def onCancel(reason,view) > @web_dialog.close > end >Do you need to close the webdialog here? It does not stop the Tool.
It is just a single stage tool. If an user presses escape I want to close the webdialog and deactivate.the_tool. Invoking
@dlg.set_on_close {Sketchup.active_model.active_view.remove_observer ProperTool::get_view_observer; **Sketchup.active_model.select_tool(nil)**}will close the tool... and will trigger @web_dialog.close again. That is why it fires up twice.
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better π
Register LoginAdvertisement