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

    Tool <> WebDialog <> Observers relationship

    Scheduled Pinned Locked Moved Developers' Forum
    23 Posts 4 Posters 1.2k 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.
    • thomthomT Offline
      thomthom
      last edited by

      
      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 with reason == 0 - and the tool should then reset itself. But the tool itself is not killed.

      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

        @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 use Sketchup.active_model.tools's push_tool and pop_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)

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

        1 Reply Last reply Reply Quote 0
        • T Offline
          tomasz
          last edited by

          @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.

          Author of [Thea Render for SketchUp](http://www.thearender.com/sketchup)

          1 Reply Last reply Reply Quote 0
          • 1
          • 2
          • 2 / 2
          • First post
            Last post
          Buy SketchPlus
          Buy SUbD
          Buy WrapR
          Buy eBook
          Buy Modelur
          Buy Vertex Tools
          Buy SketchCuisine
          Buy FormFonts

          Advertisement