Tool class
Properties of the Tool class:
Property | Explanation |
---|---|
cursor | Allows you to update your cursor when the tool is clicked. By default, the cursor is set to 0. The choices of cursor ID values are shown here: |
enabled | Returns the availability of the tool, where by default it is set to True. When this property is set to False, the tool is disabled and unavailable. This property allows you to write logic to test the state of the desktop application in order to disable or enable the tool. For example, you might have a tool that requires a data layer to be loaded in ArcMap before execution is possible. |
shape | Allows you to specify the type of shape that is drawn on the map. The shape can be used to select features, define an extent, or used as input to geoprocessing tools. After the shape is added to the map, the shape will dissappear from the display and its corresponding function is called. The functions are explained below. There are three types of shapes that can be defined:
|
Function | Explanation |
---|---|
__init__(self) | This is a Python built-in function referred to as the constructor where some initial variables can be defined. By default, the cursor and enabled properties of the tool is initially set for you. |
onDblClick(self) | Occurs when a mouse button is double-clicked when this tool is active. |
onCircle(self, circle_geometry) | Occurs when the mouse button is released after the circle is drawn on the map. circle_geometry represents a polygon object. |
onLine(self, line_geometry) | Occurs when the mouse button is double-clicked to finish drawing the line on the map. line_geometry represents a Polyline object. |
onRectangle(self, rectangle_geometry) | Occurs when the mouse button is released after the rectangle is drawn on the map. rectangle_geometry represents an Extent object. |
onMouseDown(self, x, y, button, shift) | Occurs when a mouse button is released when this tool is active.
|
onMouseDownMap(self, x, y, button, shift) | |
onMouseUp(self, x, y, button, shift) | |
onMouseUpMap(self, x, y, button, shift) | |
onKeyDown(self, keycode, shift) | Occurs when a key on the keyboard is pressed (onKeyDown) or released (onKeyUp) when this tool is active.
|
onKeyUp(self, keycode, shift) | |
deactivate(self) | Causes the tool to no longer be the active tool. |
Key code | Keys that are pressed |
---|---|
0 | No key |
1 | SHIFT key |
2 | CTRL key |
3 | SHIFT + CTRL keys |
4 | ALT key |
5 | SHIFT + ALT keys |
6 | CTRL + ALT keys |
7 | SHIFT + CTRL + ALT keys |
Button code | Mouse buttons that are pressed |
---|---|
1 | Left button |
2 | Right button |
3 | Left and Right buttons |
4 | Middle button |
5 | Left and Middle buttons |
6 | Right and Middle buttons |
7 | All buttons |