Constructor
new ToolBase(paperScope)
Create a new instance of ToolBase.
Parameters:
| Name | Type | Description |
|---|---|---|
paperScope |
paper.PaperScope | The Paper.js PaperScope object. |
- Source:
Methods
addEventListener(eventType, callback)
Add an event listener for a specific event type.
Remove the listener when no longer needed (e.g. when a UI component unmounts) via removeEventListener
to avoid stale callbacks and listener buildup.
Parameters:
| Name | Type | Description |
|---|---|---|
eventType |
string | The type of event to listen for. |
callback |
function | The callback function to be executed when the event occurs. |
- Source:
broadcast(eventType, …data)
Broadcast an event to all registered event listeners for the specified event type.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
eventType |
string | The type of event to broadcast. | |
data |
* |
<repeatable> |
Data to be passed as arguments to the event listeners. |
- Source:
clearOverlayCursorOwnedClasses()
Remove any overlay cursor CSS classes owned by this tool.
- Source:
emitItemEvent(eventType, payload)
Emit an item lifecycle event from both this tool and the project, so listeners can subscribe
either to the tool (tool-specific) or to the project (any tool). Use for item-created, item-updated, item-converted.
Emit item-updated when geometry or persisted feature state (e.g. GeoJSON-backed properties, ruler data, text) changes
so hosts can save or sync. Use toolkit-only integration events (annotationToolkit._emitIntegrationEvent) for UI or
non-persisted affordances (e.g. erase-mode toggled, live preview) where the saved feature is unchanged.
Parameters:
| Name | Type | Description |
|---|---|---|
eventType |
string | One of 'item-created', 'item-updated', 'item-converted'. |
payload |
Object | Must include { item, tool }. When a new part was added, set subpathAdded: true and include subpath: the Paper item that was added (e.g. Path or Group), so consumers can use it without guessing. |
- Source:
isActive() → {boolean}
Check if the tool is active.
- Source:
Returns:
True if the tool is active, otherwise false.
- Type
- boolean
onActivate()
Function called when the tool is activated.
- Source:
onDeactivate(shouldFinishopt)
Function called when the tool is deactivated.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
shouldFinish |
boolean |
<optional> |
false | Indicates whether the tool should finish its action. |
- Source:
projectInterface()
The project interface object containing various properties.
If a layer in the current project exists that is named "toolLayer" it will be used by the tool for graphical display
, the current active layer will be used as the tool layer.
Properties:
| Name | Type | Description |
|---|---|---|
getZoom |
function | A function to get the current zoom level. |
toolLayer |
paper.Layer | The layer used by the tool for graphical display. |
paperScope |
paper.PaperScope | The Paper.js PaperScope object. |
overlay |
Element | The overlay element used by the tool. |
- Source:
registerOverlayCursorOwnedClasses(…classes)
Register overlay cursor CSS classes that this tool may add during interaction.
These are considered owned by this tool and can be cleared on deactivate.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
classes |
string | Array.<string> |
<repeatable> |
- Source:
removeEventListener(eventType, callback)
Remove an event listener. Removes the first registered listener for eventType that is === callback.
Use the same function reference that was passed to addEventListener. No-op if the callback was never added or was already removed.
Parameters:
| Name | Type | Description |
|---|---|---|
eventType |
string | The type of event. |
callback |
function | The callback to remove (must be the same reference used in addEventListener). |
- Source: