Exit a Tool with ESC Key

I would like to make it possible to exit any of my tools with the ESC key (Escape). Does anyone have an example or know how to do that?

I find this feature very handy within other drafting programs, and it would increase the speed with which you could use the plugin.

It is more traditional with SketchUp tools, that the ESC key resets the current tool to initial state.

Use onCancel method within a tool.

This seems to do the trick:

def onCancel(flag, view)
	if flag == 0
		Sketchup.active_model.select_tool(nil)
	else
		view.invalidate if @drawn
    		reset
	end
    	
end

With the window and door creation tools the user only needs to make one click of the mouse to create a new opening. Hence there is no need for a reset or return to initial state for this particular tool. Essentially it is always in its initial state. Once you create the opening the geometry creation is executed and then the tool resets so you can create another opening on the same wall panel or a different one.

In this case it makes more sense that the ESC key actually exits the tool completely.

I disagree. The user can always hit the spacebar to switch to the SelectionTool.

What this does is teach the unsuspecting that the ESC key is for something other than it should be.
Normally, ONLY interrupter view tools (Pan Orbit, Zoom) use the ESC key to return to previous tool when they’ve interrupted edit type tools.

But in the absence of an “official” tools guidelines, do want ya’ like.

2 Likes

I guess I’m too used to using other CAD programs, I should probably stick with the standard operating procedure for SU.

As, I said, if this tool has interrupted some other tool, you can push the previous tool back on the toolstack.

1 Like

As Dan says this would be a non-standard behavior in SketchUp. In e.g. SolidWorks the select tool is fundamentally different in the way that “exiting” any other tool takes you “back” to it. In SketchUp select tool has no such special position. It is just a tool like any other tool, but active on SketchUp start and associated with the biggest button on the keyboard.

I’m very accustomed to being able to hit the ESC key to jump out of a command or function, particularly in AutoCAD, where I do most of my 2D work. So long as the space bar can dump me out of the tool, that should suffice.

Except that SketchUp does not have any “limbo” (no active command) mode like AutoCAD.

In SketchUp there is (or should be) always some kind of tool set as the active tool. (There are times when this doesn’t happen, usually during Ruby code execution, and this used to cause BugSplats. I can tell when this happens, because my system cursors are bright orange, and I see the orange default arrow system cursor over the modeling area.
When this strange “no tool” situation happens the Sketchup.active_model.tools.active_tool_id == 0 and other tool methods should not be called as crashes could happen.)

Any keyboard accelerator that activates any other tool will also exit your tool (as well as any other.)

So, you were just thinking in command mode which SketchUp does not have.

1 Like

I am slowly learning how this system works.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.