vagran / dxf-viewer

DXF 2D viewer written in JavaScript
Mozilla Public License 2.0
290 stars 86 forks source link

can export a click event? #57

Closed ChinaBruce closed 1 year ago

ChinaBruce commented 1 year ago

hi Can there be a click event in dxf-viewer? I want to obtain information about clicked icons through click events.

thanks.

vagran commented 1 year ago

Hi! Events (CustomEvent) are emitted for canvas element, which you can get by DxfViewer.GetCanvas() method. Event names are prefixed by __dxf_. For pointer event position property is added with model space coordinates. Original event is available in domEvent property. For now only pointerdown and pointerup are re-emitted in such a way. Most probably this interface will be changed in the future.

viewer.GetCanvas().addEventListener("__dxf_pointerdown", e => console.log(e.details.position))