Event Callbacks
yucad notifies the host by calling __stdcall function
pointers the host registers — never the reverse.
Registering
Each event type has a CadOnEvent* registrar taking one function
pointer. Registering again replaces the previous callback; passing null clears it.
There is one callback slot per event type per process, matching Vecad.
void __stdcall onMove(YuHandle hDwg, double x, double y){ /* world coords */ }
CadOnEventMouseMove(onMove);
void __stdcall onCmdFinish(YuHandle hDwg, int cmdId){ /* command completed */ }
CadOnEventCmdFinish(onCmdFinish);
Callback contract
- Callbacks use
__stdcall, exactly like the exports. - They fire on the document's UI thread, synchronously, during the yucad call or message dispatch that triggered them — so it is safe to call back into yucad from inside a handler for the same document.
- Handlers should return promptly; long work blocks the viewport.
Event categories
| Category | Examples | Fires when |
|---|---|---|
| Pointer | MouseMove, MouseDown, MouseUp |
the user moves/clicks in the viewport (world coordinates supplied). |
| Selection | EntSelect, selection-changed |
an entity is picked or the selection set changes. |
| Command | CmdStart, CmdFinish, CmdCancel |
an interactive command begins, commits or aborts. |
| Document | entity added / changed / erased, modified flag, load & save | the model changes or files are read/written. |
| View | zoom / pan changed | the viewport transform updates. |
| Custom entities | the CEnt* callbacks |
a host-defined entity needs to draw, hit-test, report properties, or be transformed (see below). |
Custom entities & commands
A host can define its own entity types and commands: yucad calls back for display,
grip points, hit-testing, transforms and a name/property list, and drives the whole
lifecycle through the custom-entity (CEnt*) callback family and the
custom-command family. This lets a host render and edit domain objects the core
engine has no built-in knowledge of, while still participating in selection, undo and
DXF round-tripping.
Callback signatures must match the ABI exactly — the wrong
prototype corrupts the stack under
__stdcall. Consult the
Function Reference entry for each registrar before
defining its handler.