Tool <> WebDialog <> Observers relationship
-
def onCancel(reason,view) @web_dialog.close end
Do 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_tool
andpop_tool
so 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.
Advertisement