Class: Sketchup::ToolsObserver Abstract
Relationships | |
Inherits: | Object |
Overview
To implement this observer, create a Ruby class of this type, override the desired methods, and add an instance of the observer to the Tools
object.
This observer interface is implemented to react to tool events.
Some of the code below mentions tool_names
and tool_ids
. Here is a list of the common tool IDs and names:
-
21013
= 3DTextTool -
21065
= ArcTool -
10523
= CameraDollyTool -
10508
= CameraOrbitTool -
10525
= CameraPanTool -
21169
= PositionCameraTool -
10520
= CameraWalkTool -
10509
= CameraZoomTool -
10526
= CameraZoomWindowTool -
21096
= CircleTool -
21013
= ComponentTool -
21126
= ComponentCSTool -
21410
= DimensionTool -
21019
= EraseTool -
21031
= FreehandTool -
21525
= ExtrudeTool -
21126
= SketchCSTool -
21048
= MoveTool -
21024
= MeasureTool -
21100
= OffsetTool -
21074
= PaintTool -
21013
= PasteTool -
21095
= PolyTool -
21515
= PositionTextureTool -
21041
= PushPullTool -
21057
= ProtractorTool -
21094
= RectangleTool -
21129
= RotateTool -
21236
= ScaleTool -
21022
= SelectionTool -
21337
= SectionPlaneTool -
21020
= SketchTool -
21405
= TextTool
Instance Method Summary
-
#onActiveToolChanged(tools, tool_name, tool_id) ⇒ nil
Once you subclass
ToolsObserver
with your unique class, you can override the #onActiveToolChanged method to receive tool change notifications. -
#onToolStateChanged(tools, tool_name, tool_id, tool_state) ⇒ nil
The #onToolStateChanged method is called each time the user performs an action with a tool.
Instance Method Details
#onActiveToolChanged(tools, tool_name, tool_id) ⇒ nil
In SketchUp 6 and SketchUp 7.0, tool names on the Mac have some of their first characters truncated. For instance, on Windows, a tool is “CameraOrbit”. On the Mac, is comes across as “raOrbit”. Therefore, use the tool_id
to keep track of which tool you need to watch for, or use logic that corrects for the error. There is an example method of one way to do this shown below. (This example is not a comprehensive list of the tool names.)
Once you subclass ToolsObserver
with your unique class, you can override the #onActiveToolChanged
method to receive tool change notifications.
#onToolStateChanged(tools, tool_name, tool_id, tool_state) ⇒ nil
In SketchUp 6 and SketchUp 7, tool names on the Mac have their first few characters truncated. For instance, on Windows, a tool is “CameraOrbit”. On the Mac, is comes across as “raOrbit”. Therefore, use the tool_id to keep track of which tool you need to watch for, or use logic that corrects for the error. This bug was fixed in SketchUp 8.0.
The #onToolStateChanged
method is called each time the user performs an action with a tool. The actual state that is returned is an internal number that varies tool to tool. If you want to watch existing tools for every interaction, you will need to experiment with the tool state to determine which states you care about. There is little consistency tool to tool.